我以为我做了一段时间的事情,但后来我遇到了无限打印结果行的问题。现在我根本无法让它工作。有谁知道如何将这种代码风格变成符合我既定目标的功能?
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);
}
}
}