Hello , I'm attempting complete my Java code but I'm getting an error import java.util.Scanner; public class GradeCalculatorFinal.java{ public static void main(String[] args) { // Total points / total credits // points for a class = grade value * credits // A = 4, B = 3, C = 2, D = 1.... Scanner scanner = new Scanner(System.in); System.out.println("Enter grade:"); String grade = scanner.nextLine(); Integer points = 0; Integer gradeValue = 0; if (grade.equalsIgnoreCase("A")) { gradeValue = 4; } else if (grade.equalsIgnoreCase("B")) { gradeValue = 3; } else if (grade.equalsIgnoreCase("C")) { gradeValue = 2; } else if (grade.equalsIgnoreCase("D")) { gradeValue = 1; } else if (grade.equalsIgnoreCase("F")) { gradeValue = 0; } else { System.out.println("You didn't enter a valid grade :("); } Integer points = gradeValue * Integer.parseInt(credits); Integer gpa = points / Integer.parseInt(credits); System.out.println("Credits: " + credits); System.out.println("Grades: " + grades); System.out.println("Points: " + points); System.out.println("GPA: " + gpa); scanner.close(); } }
Hello , I'm attempting complete my Java code but I'm getting an error
import java.util.Scanner;
public class GradeCalculatorFinal.java{
public static void main(String[] args) {
// Total points / total credits
// points for a class = grade value * credits
// A = 4, B = 3, C = 2, D = 1....
Scanner scanner = new Scanner(System.in);
System.out.println("Enter grade:");
String grade = scanner.nextLine();
Integer points = 0;
Integer gradeValue = 0;
if (grade.equalsIgnoreCase("A")) {
gradeValue = 4;
} else if (grade.equalsIgnoreCase("B")) {
gradeValue = 3;
} else if (grade.equalsIgnoreCase("C")) {
gradeValue = 2;
} else if (grade.equalsIgnoreCase("D")) {
gradeValue = 1;
} else if (grade.equalsIgnoreCase("F")) {
gradeValue = 0;
} else {
System.out.println("You didn't enter a valid grade :(");
}
Integer points = gradeValue * Integer.parseInt(credits);
Integer gpa = points / Integer.parseInt(credits);
System.out.println("Credits: " + credits);
System.out.println("Grades: " + grades);
System.out.println("Points: " + points);
System.out.println("GPA: " + gpa);
scanner.close();
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images