Advertisement
Cryorus

Untitled

Jul 13th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. package javaapplication28;
  2. import java.util.*;
  3.  
  4. /**
  5.  *
  6.  * @author Cryorus
  7.  * Calculos de promedio IP CIISA
  8.  */
  9. public class Main {
  10.  
  11.     public static void main(String[] args) {
  12.         Scanner entrada = new Scanner(System.in);
  13.         System.out.print("Ingrese total de notas: ");
  14.         short total = entrada.nextShort();
  15.         short notas[]; notas = new short[total];
  16.         short porc[]; porc = new short[total];
  17.         short promedio = 0;
  18.  
  19.         System.out.println("Formato de notas: 10, 15, 70\nSi la nota es desconocida ingrese nota 0");
  20.         for(short i = 0; i < notas.length; i++){
  21.             System.out.print("Ingrese nota " + (i+1) + ": ");
  22.             notas[i] = entrada.nextShort();
  23.             System.out.print("Ingrese porcentaje de nota " + (i+1) + ": ");
  24.             porc[i] = entrada.nextShort();
  25.         }
  26.  
  27.         for(short i = 0; i < notas.length; i++) {
  28.             if(notas[i]!=0) {
  29.                 promedio += notas[i]*porc[i];
  30.             }
  31.         }
  32.  
  33.         for(short i = 0; i < notas.length; i++) {
  34.             if(notas[i] == 0) {
  35.                 for(short n = 1; n <= 70; n++) {
  36.                     short promedio2 = promedio;
  37.                     promedio2 += n*porc[i];
  38.                     if(promedio2/100 >= 40) {
  39.                         System.out.println("La nota necesaria es: " + n);
  40.                         break;
  41.                     }
  42.                     else {
  43.                         promedio2 = promedio;
  44.                     }
  45.                 }
  46.             }
  47.         }
  48.  
  49.         System.out.println("Promedio: " + promedio/100);
  50.  
  51.     }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement