i got a H.W requires to find the the 2 max numbers of 4 input numbers
i tried to do it with if statement but i think i am going the wrong way , we only took if statement and while loop , so i must use them , the possibilities are too much i cant continue this way i guess. what do you think ? , thanks.
if ((a>b && b>c && c>d)||(a>b && b>d && d>c)){
System.out.println("max1 is : " + a);
System.out.println("max2 is : " + b);}
else if ((b>a && a>c && c>d)||(b>a && a>c && d>c) ){
System.out.println("max1 is : " + b);
System.out.println("max2 is : " + a);}
if ((c>a && a>b && b>d)||(c>a && a>b && d>b)){
System.out.println("max1 is : " + c);
System.out.println("max2 is : " + a);}
Aucun commentaire:
Enregistrer un commentaire