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