Create a java program that will calculate the current grade in a classroom. The program should ask for 5 grades as well as total point value per grade available.
Do you have more students to enter? Y or N Y
Enter First Name: Sam
Enter Last Name: Smith
Please enter grade > 0 1 : 22
Please enter grade > 0 2 : 21
Please enter grade > 0 3 : 24
Please enter grade > 0 4 : 20
Please enter grade > 0 5 : 19
Student: Sam Smith
mean: 0.71
grade: C-
Do you have more students to enter? Y or N N
Overall mean: 0.85
Overall grade: B
Lab2 Ending
Sure! Here's a Java program that calculates the current grade in a classroom based on 5 grades and the total point value per grade available:
```java
import java.util.Scanner;
public class GradeCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double totalPoints = 0;
double totalScore = 0;
// Get input for each grade and its respective point value
for (int i = 1; i <= 5; i++) {
System.out.print("Enter grade " + i + ": ");
double grade = scanner.nextDouble();
System.out.print("Enter total point value for grade " + i + ": ");
double pointValue = scanner.nextDouble();
totalPoints += pointValue;
totalScore += (grade * pointValue);
}
scanner.close();
// Calculate the current grade
double currentGrade = (totalScore / totalPoints) * 100;
System.out.println("Your current grade is: " + currentGrade);
}
}
```
To run this program, you can follow these steps:
1. Open a text editor and copy the above code into a new file. Save the file with a `.java` extension, such as `GradeCalculator.java`.
2. Make sure you have Java installed on your computer.
3. Open a command prompt or terminal and navigate to the directory where you saved the `GradeCalculator.java` file.
4. Compile the Java file by running the following command: `javac GradeCalculator.java`
5. After the compilation is successful, run the program using the following command: `java GradeCalculator`
6. The program will ask you to enter the grade and total point value for each of the 5 grades. Input the values accordingly.
7. After entering all the grades and point values, the program will display your current grade.
Note: This program assumes that the point value for each grade remains constant. If the point values vary for each grade, you may need to modify the code accordingly.