In Java
Main method
Your main program will prompt the user for a test name and the number of scores the user will enter. After creating an arraylist to hold the scores, prompt the user for all the scores to hold in the arraylist. After all the scores are entered, then repeat back the score & letter grade.
GradeBook Object
Create an instance of a GradeBook object and pass the test name and arraylist to set the instance variables. At some point (inside a constructor or some other method), call a user-created method called setLetterGrades( ) that will set the letter grades that corresponds to the scores arraylist.
*There are multiple ways to set this up. You pick. Again, ultimate freedom. Get used to it.
Verify that the GradeBook object has getter and setter methods for all instance variables. Also, include a default no-argument constructor.
Use the chart below to figure out the appropriate letter grade.
|
Score (Greater than or equal to) |
Letter Grade |
|
90 |
A |
|
80 |
B |
|
70 |
C |
|
60 |
D |
|
Less than 60 |
F |
Get the values back into the main program and print everything out.
Your output should look something like the example on page 2, with the user selecting different numbers for the scores array each time the program is ran or using a sentinel value loop.
Sample run
How many scores would you like to enter? 5
Enter a score: 46
Enter a score: 64
Enter a score: 72
Enter a score: 86
Enter a score: 94
Score -------- Grade
46 -------- F
64 -------- D
72 -------- C
86 -------- B
94 -------- A
The Java code for the above question is given below:
import java.util.*;
/**
* GradeBook Class
*/
public class GradeBook {
/**
* Data members of the class
* testName -- it denotes the name of the test
* letterGrades --- arraylist which denotes the letter grades of the score
* scores ----- arraylist which denotes the scores
*/
private String testName;
private ArrayList<Character> letterGrades;
private ArrayList<Integer> scores;
/**
* Default constructor
*/
GradeBook() {
testName = "sample test";
}
/**
* Parameterized constructor
* parameters : name of the test and arraylist of scores
*/
GradeBook(String name, ArrayList<Integer> arr) {
testName = name;
scores = arr;
letterGrades = calculateLetterGrades(arr); // method to convert the score to letterGrades
}
/**
* Method to convert the scores to the letterGrades
* It returns an arrayList of characters storing the lettergrades
*/
public ArrayList<Character> calculateLetterGrades(ArrayList<Integer> arr) {
ArrayList<Character> grade = new ArrayList<Character>(arr.size());
for(int i=0;i<arr.size();i++) {
if(arr.get(i) >= 90)
grade.add('A');
else if(arr.get(i) >= 80)
grade.add('B');
else if (arr.get(i) >= 70)
grade.add('C');
else if (arr.get(i) >= 60)
grade.add('D');
else
grade.add('F');
}
return grade;
}
/**
* Getters and Setters
*/
public String getTestName() {
return testName;
}
public void setTestName(String testName) {
this.testName = testName;
}
public ArrayList<Character> getLetterGrades() {
return letterGrades;
}
public void setLetterGrades(ArrayList<Character> letterGrades) {
this.letterGrades = letterGrades;
}
public ArrayList<Integer> getScores() {
return scores;
}
public void setScores(ArrayList<Integer> scores) {
this.scores = scores;
}
/**
* Main Method
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String testName;
System.out.print("Enter Test Name : ");
testName = scan.nextLine(); // input the test name
int numberOfScores;
System.out.print("How many scores would you like to enter? ");
numberOfScores = scan.nextInt(); // input the number of scores
ArrayList<Integer> arr = new ArrayList<Integer>(numberOfScores);
for(int i=0;i<numberOfScores;i++) {
System.out.print("Enter a Score: ");
int score = scan.nextInt(); // input the scores
arr.add(score);
}
GradeBook gradeBook = new GradeBook(testName, arr); // create an instance of GradeBook class
ArrayList<Character> letterGrades = gradeBook.getLetterGrades(); // getting the letterGrades
ArrayList<Integer> scores = gradeBook.getScores(); // getting the scores
System.out.println("Score -------- Grade");
for(int i=0;i<scores.size();i++) {
System.out.println(scores.get(i) + " -------- " + letterGrades.get(i));
}
}
}
Sample Input and Output:
Screenshot of the code is given below:


If the answer helped please upvote, it means a lot and for any query please comment.
In Java Main method Your main program will prompt the user for a test name and...
using java
Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...
Complete the following Java class. In this class, inside the main() method, user first enters the name of the students in a while loop. Then, in an enhanced for loop, and by using the method getScores(), user enters the grades of each student. Finally, the list of the students and their final scores will be printed out using a for loop. Using the comments provided, complete the code in methods finalScore(), minimum(), and sum(). import java.util.Scanner; import java.util.ArrayList; public class...
Write a javascript program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage—This method should accept five test scores as arguments and return the average of the scores. determineGrade—This method should accept a test score as an argument and return a letter grade for the score,
Create a C++ program to : Prompt user for seven test score Store the scores into an array Print the array before and after sorting Print the test average Convert the average to letter grade Search for a test score 90, using linear search Print, if test score 90 was found and at what position Add Comments SEPARATE THE FILES INTO 3 : header.h, functions.cpp, main.cpp
Create a C++ program to : Prompt user for seven test score Store the scores into an array Print the array before and after sorting Print the test average Convert the average to letter grade Search for a test score 90, using linear search Print, if test score 90 was found and at what position Add Comments SEPARATE THE FILES INTO 3 : header.h, functions.cpp, main.cpp
Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....
Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and letterGrade. The user will type a line of input containing the student's name, then a number that represents the number of scores, followed by that many integer scores (user input is in bold below). The data type used for the input should be one of the primitive integer data types. Here are two example dialogues: Enter a student record: Maria 5 72 91 84...
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Round the average...
Create a Java program that uses methods. In the main method, the program must prompt the user for a Social Security Number in the following format: DDD-DD-DDDD, where D is a digit. The program must call a method called “validate” that must receive the inputted SSN from the main method and decide whether the inputted number is valid and return the decision to the main method. Then, the main method must print the decision.
Write a grading program in Java for a class with the following grading policies: There are three quizzes, each graded on the basis of 10 points. There is one midterm exam, graded on the basis of 100 points. There is one final exam, graded on the basis of 100 points. The final exam counts for 40% of the grade. The midterm counts for 35% of the grade. The three quizzes together count for a total of 25% of the grade....