Help with a code condition

0

I have the following code.

package p01;
import java.util.Scanner;

public class P01 {
private String estudiante;
private String nombre; 

public static void main(String[] args) {
    String[] estudiante = {"Nahum Deavila","Genesis Machado","Juan Giraldo","Jose Diana","Cindy Salazar"};
     double[] definitiva = {1.0,2.0,3.0,4.0,5.0};
     int i;

       for (i = 0; i < definitiva.length; i++) {
                 System.out.print("Estudiante " + estudiante[i] + " Definitiva : " + definitiva[i] + "\n");
   }
  }
}

'

How can I do so that instead of printing the name and the definitive one I can put a condition that if it is higher than 3.0 it approved the subject. I do not know how to fit it in the code. Thanks.

    
asked by Nahum Deavila 18.05.2016 в 17:47
source

1 answer

0

You must add a if where the definitive is greater than 3:

for (i = 0; i < definitiva.length; i++) {
    if(definitiva[i] > 3.0){
        System.out.print("Aprobado\n");
    }else {
        System.out.print("Estudiante " + estudiante[i] + " Definitiva : " + definitiva[i] + "\n");
    }
}
    
answered by 18.05.2016 / 18:02
source