Hello I'm new in programming and I have some task :
TASK: In the Main.java file create three variables, with the names nr1, nr2, nr3, which store integers. Next, use the conditional statement if ... elseif ... else, write on the page which one is the largest. The string to be printed is to be by "The largest of the numbers 9,3,15 is 15."
public class Main2 {
public static void main(String[] args) {
int nr1 = 24;
int nr2 = 36;
int nr3 = 15;
if (nr2 > nr1) {
System.out.println("The largest of the numbers 15,24,36 is 36");
} else if (nr2 > nr3) {
System.out.println("The largest of the numbers 15,24,36 is 36");
} else {
System.out.println("error");
}
}
}
Am I doing it right?
Aucun commentaire:
Enregistrer un commentaire