我的代码是"完成"但是我遇到了错误:
"找不到符号"
import java.util.*;
public class OrderNumbers
{
public static void main (String [] args)
{
Scanner scan = new Scanner(System.in);
int input1;
int input2;
int input3;
System.out.print("Enter the first number: ");
input1 = scan.nextInt();
System.out.print("Enter the second number: ");
input2 = scan.nextInt();
System.out.print("Enter the third number: ");
input3 = scan.nextInt();
}
{if ((input1 > input2 && input1 > input3))
{ if (input2 > input3)
{
System.out.print(input3 + "," + input2 + "," + input1);
}
else
System.out.print(input2 + "," + input3 + "," +input1);
}
else if ((input2 > input1 && input2 > input3))
{if (input1 > input3)
{
System.out.print(input3 + "," + input1 + "," + input2);
}
else
{
System.out.print(input1 + "," + input3 + "," + input2);
}
}
else if ((input3 > input1 && input3 > input2))
{if (input1 > input2)
{
System.out.print(input2 + "," + input1 + "," + input3);
}
else
System.out.print(input1 + "," + input2 + "," + input3);
}
else
{
System.out.println("ERROR!");
}
}
}
我已经阅读了很多论坛,似乎常见的问题是大多数人并没有在合适的空间宣布,但我确实相信自己。
答案 0 :(得分:1)
main
方法。}
{if ((input1 > input2 && input1 > input3))
删除这些{
}
,问题将得到解决。
也就是说,格式化您的代码,如果您使用Eclipse 等IDE,这很容易。这是在此代码上使用 Ctrl + Shift + F 后代码的样子:
import java.util.*;
public class OrderNumbers {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int input1;
int input2;
int input3;
System.out.print("Enter the first number: ");
input1 = scan.nextInt();
System.out.print("Enter the second number: ");
input2 = scan.nextInt();
System.out.print("Enter the third number: ");
input3 = scan.nextInt();
}
{
if ((input1 > input2 && input1 > input3))
{
if (input2 > input3) {
System.out.print(input3 + "," + input2 + "," + input1);
} else
System.out.print(input2 + "," + input3 + "," + input1);
} else if ((input2 > input1 && input2 > input3))
{
if (input1 > input3) {
System.out.print(input3 + "," + input1 + "," + input2);
} else {
System.out.print(input1 + "," + input3 + "," + input2);
}
} else if ((input3 > input1 && input3 > input2))
{
if (input1 > input2) {
System.out.print(input2 + "," + input1 + "," + input3);
} else
System.out.print(input1 + "," + input2 + "," + input3);
} else {
System.out.println("ERROR!");
}
}
}
您认为在格式化代码时问题有多明显吗?