我真的是java新手(第三周上课),但我一直在尝试处理这段代码几个小时,但我似乎无法找到我正在做的事情的答案。javac 告诉我我只有三个错误,但我想知道是否还有更多错误。这是我的代码,我知道我的平均部分仍然需要工作,但我无法弄清楚 if 和 else 语句的中间部分发生了什么。对不起,如果这真的很愚蠢,我确定我的语法到处都是:
import java.util.Scanner;
public class Program1
{
static public void main( String args [ ] )
{
int grade;
int A,B,C,D,F;
A = 0;
B = 0;
C = 0;
D = 0;
F = 0;
System.out.println( "*************** Grade Computer *************");
// ********************** //
Scanner kbd = new Scanner (System.in);
System.out.println("Enter Students First Name: ");
String fname = kbd.next( );
System.out.println("Enter Students Middle Initial: ");
String mi = kbd.next( );
System.out.println("Enter Students Last Name: ");
String lname = kbd.next( );
System.out.println("Enter First Exam Grade: ");
int firstexam = kbd.nextInt( );
System.out.println("Enter Second Exam Grade: ");
int secondexam = kbd.nextInt( );
System.out.println("Enter Third Exam Grade: ");
int thirdexam = kbd.nextInt( );
System.out.println("Was the bonus done? [yes/no] : ");
boolean b = kbd.nextBoolean( );
boolean yes = true;
boolean no = false;
// *********************** //
if(true)
{
{
if((firstexam >= (secondexam * 0.60 ) ) & (firstexam >= (thirdexam * 0.80 )));
{
System.out.println(firstexam);
}
else if((secondexam * 0.60) >= (thirdexam * 0.80));
{
System.out.println(secondexam * 0.60);
}
else {
System.out.println(thirdexam * 0.80);
}
}
if(true)
{
if((secondexam >= firstexam) & ((thirdexam * 0.80) >= secondexam));
{
if(secondexam >= (thirdexam * 0.80));
{
System.out.println(secondexam);
}
}
else {
System.out.println(thirdexam * 0.80);
}
}
else {
System.out.println(firstexam);
System.out.println(secondexam);
System.out.println(thirdexam);
}
}
// ********************** //
System.out.println(" **********Grade Summary********** ");
double average = calcAverage(firstexam, secondexam, thirdexam);
System.out.println("Grade Report For: " + fname);
if (true)
{
System.out.println("Bonus was done so grades are adjusted if appropriate.");
}
else
{
System.out.println("Bonus was not done.");
}
System.out.println("Exam 1: " + firstexam);
System.out.println("Exam 2: " + secondexam);
System.out.println("Exam 3: " + thirdexam);
System.out.println("The average is: " + average);
determineGrade(average);
}
public static double calcAverage(int firstexam, int secondexam, int thirdexam)
{
double average = (firstexam + secondexam + thirdexam) / 3.0;
return average;
}
public static void determineGrade(double average)
{
if (average>90)
{
System.out.println("Grade: A");
}
else if (average>=80)
{
System.out.println("Grade: B");
}
else if (average>=70)
{
System.out.println("Grade: C");
}
else if (average>=60)
{
System.out.println("Grade: D");
}
else if (average<60)
{
System.out.println("Grade: F");
}
}
// ************** //
}