0
我试图获取用户输入的最高和最低编号。我懂了。我只是新编程。有3个错误。Java代码中的错误
import java.io.*;
public class HighestToLowest
{
public static void main(String []args)throws IOException{
{
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
double[] input = new double[8];
int index;
int highIndex = 0;
int lowIndex = 0;
double sum = 0;
System.out.println("Enter The Scores Of Judges: ");
for (index = 0; index<8; index++){
System.out.print("Enter The Score" + (index + 1) + ": ");
input[index] = Double.parseDouble(dataIn.readLine());
}
for (index = 1; index < 8; index++)
if(input[highIndex] < input[index])
highIndex = index;
for (index = 1; index < 8; index++)
if (input[lowIndex] > input[index])
lowIndex = index;
for (index = 0; index < 8; index++)
sum = sum + input[index];
try
{
input[index] = Double.parseDouble(dataIn.readLine());
}
catch(IOException e)
{
System.out.println("error");
}
if(sum>index)
{
sum=highIndex;
}
if(sum>=index)
{
index=lowIndex;
}
}
System.out.print("Highest is: + highIndex");
System.out.print("Lowest is: + lowIndex");
System.out.printf("The Contestant Receives a total of %.2f", (sum - highIndex - lowIndex));
}
}
有什么错误? – nos 2011-03-16 16:50:22
无论何时您遇到错误消息,请始终在提示您提供问题的线路和完整的消息中发帖。 – jzd 2011-03-16 16:50:48
下次尝试将问题放在问题的“正文”中,而不是“标题”。 – adarshr 2011-03-16 16:50:54