しばらく何かに取り組んでいると思っていましたが、結果の行が無限に印刷されるという問題がありました。今、私はそれをまったく機能させることができません。このコードスタイルを、私の述べた目標のために機能的なものに変える方法を知っている人はいますか?
import java.util.Scanner;
public class Numerical
{
public static void main (String [ ] args )
{
Scanner scan = new Scanner (System.in);
System.out.println("Please enter 5 numbers one after another");
{
int a = scan.nextInt ( ); // First number input by user
int b = scan.nextInt ( ); // Second number input by user
int c = scan.nextInt ( ); // Third number input by user
int d = scan.nextInt ( ); // Fourth number input by user
int e = scan.nextInt ( ); // Fifth number input by user
// Check if a is the greatest number
if (a > b);
while(a > c);
while(a > d);
while(a > e);
System.out.println ("The highest number is " +a);
// Check if b is the greatest number
else if (b > a);
while(b > c);
while(b > d);
while(b > e);
System.out.println ("The highest number is " +b);
// Check if c is the greatest number
else if(c > a);
while(c > b);
while(c > d);
while(c > e);
System.out.println ("The highest number is " +c);
// Check if d is the greatest number
else if(d > a);
while(d > b);
while(d > c);
while(d > e);
System.out.println ("The highest number is " +d);
// Check if e is the greatest number
else if(e > a);
while(e > b);
while(e > c);
while(e > d);
System.out.println ("The highest number is " +e);
}
}
}