Question

In: Computer Science

write a program called GradeCalculator that will calculate the grading statistics of a desired number of...

write a program called GradeCalculator that will calculate the grading statistics of a desired number of students.

Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will also check for negative scores. If any score is negative, it will prompt the user to reenter the scores. You do not have to deal with inputs that are not numbers.  

For each student, calculate the student’s the average score, lowest score, highest score, letter grade, and the number of stars to give the student. Once the letter grade has been calculated, use it to calculate an appropriate number of stars the student will received. The letter grade is computed as followed: 90 to 100 is A, 80 and less than 90 is B, 70 and less than 80 is C, 60 and less than 70 is D, anything less than 60 is F. The number of stars is assigned as followed: A is 4 stars, B is 3 stars, C is 2 stars, D is 1 star, and F is 0 stars (no star). The program then displays the statistics about the student as shown in the sample run.

Before the program terminates, it prints the class statistics: average grade, lowest grade, highest. See sample output for format.

See sample run to have a better idea of what the program should do.

Grading:

program is expected to have comments.  Also comment code that is not obvious. Your program should be beautifully format, well designed, and efficient. Your program should perform as described. Try to match your output with the same run.

Sample Run:

Welcome to GradeCalculator!

Please enter the number of students: 2 Please enter the number of exams   : 3

---------------------------------------- Enter student 1’s name : Micheal Brown

Enter exam scores : 90 100 -80

Invalid exam scores, reenter: 90 100 80

Grade statistics for Micheal Brown   Average: 90   Letter grade: A   Micheal Brown gets 4 stars! ****

---------------------------------------- Enter student 2’s name: Will Smith

Enter exam scores: 80 95 70

Grade statistics for Will Smith   Average: 81.66   Letter grade: C   Will Smith gets 2 stars! **

---------------------------------------- Class statistics:   Average: 85.83   Lowest : 81.66   Highest: 90

Done. Good bye!

Solutions

Expert Solution

import java.util.Scanner;


public class GradeCalculator {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Welcome to GradeCalculator!");
System.out.print("Please enter the number of students: ");
int numStud = sc.nextInt();
System.out.print("Please enter the number of exams : ");
int examNum = sc.nextInt();
int []scores = new int[examNum];
int i = 0, num = 0;
double high = 0, low = 0;
while(i < numStud){
System.out.print("Enter student "+(i+1)+"'s name : ");
sc = new Scanner(System.in);
String name = sc.nextLine();
int flag = 0,sum = 0;
System.out.print("Enter exam scores : ");
do{
  
for (int j = 0; j < scores.length; j++) {
scores[num] = sc.nextInt();
sum+=scores[num];
}
for (int j = 0; j < scores.length; j++) {
if(scores[i] < 0){
break;
}else{
flag = 1;
}
}
if(flag == 1){
break;
}else{
System.out.print("Invalid exam scores, reenter: ");
sum = 0;
}
  
}while(true);
double avg = ((double)sum/examNum);
if(avg >= 90 && avg <=100 ){
high = avg;
System.out.print("Grade statistics for "+name);
System.out.printf("Average: %.2f",avg);   
System.out.print(" Letter grade: A "+name+ " gets 4 stars! ****\n");
}else if(avg>=80 && avg <90){
low = avg;
System.out.print("Grade statistics for "+name);
System.out.printf("Average: %.2f",avg);
System.out.print(" Letter grade: B " +name+" gets 3 stars! ***\n");
}else if(avg >= 70 && avg < 80){
low = avg;
System.out.print("Grade statistics for "+name);
System.out.printf("Average: %.2f",avg);
System.out.print("Letter grade: C " +name+" gets 2 stars! **\n");
}else if(avg >= 60 && avg < 70){
low = avg;
System.out.print("Grade statistics for "+name);
System.out.printf("Average: %.2f",avg);
}else{System.out.print(" Letter grade: D " +name+" gets 2 stars! *\n");
low = avg;
System.out.print("Grade statistics for "+name);
System.out.printf("Average: %.2f",avg);
System.out.println( "Letter grade: D " +name+" gets 0 star!\n");
}
i++;
}
System.out.print("Class Statistics: Average: ");
System.out.printf("%.2f ",((double)(high+low)/2));
System.out.printf("Lowest : %.2f ",low);
System.out.printf("Highest: %.2f \n",high);
System.out.println("Done. Good bye!");
}
}
/* OUTPUT */

run:
Welcome to GradeCalculator!
Please enter the number of students: 2
Please enter the number of exams : 3
Enter student 1's name : Micheal Brown
Enter exam scores : 90 100 -80
Invalid exam scores, reenter: 90 100 80
Grade statistics for Micheal BrownAverage: 90.00 Letter grade: A Micheal Brown gets 4 stars! ****
Enter student 2's name : Will Smith
Enter exam scores : 80 95 70
Grade statistics for Will SmithAverage: 81.67 Letter grade: B Will Smith gets 3 stars! ***
Class Statistics: Average: 85.83 Lowest : 81.67 Highest: 90.00
Done. Good bye!


Related Solutions

Write a grading program for a class with the following grading policies: There are three quizzes,...
Write a grading program for a class with the following grading policies: There are three quizzes, each graded on the basis of 10 points. There is one miterm exm, graded on the basis of 100 points. There is one finl exm, graded on the basis of 100 points. The fnal exm counts for 40% of the grade. The miterm counts for 35% of the grade. The three quizzes together count for a total of 25% of the grade. (Do not...
Write a program that converts the user's number into the desired unit of measurement. The user...
Write a program that converts the user's number into the desired unit of measurement. The user will pick the desired unit from a menu shown below. Ask the follow-up question (the number to convert) and do the math ONLY if the user picks a valid choice from the menu. You can see the conversions / multipliers needed for this program in the output section below. Menu/Prompt: Enter the number that corresponds to your desired unit conversion from the choices below:...
You are required to write a program to provide the statistics of a file (Number of...
You are required to write a program to provide the statistics of a file (Number of letters, number of words, number of vowels, number of special characters and number of digits. You should implement this problem as a class and call it FileContentStats which provides statistics about the number of letters, number of words, number of vowels, number of special characters, number of lines and number of digits. All of these should be private data members. (Should be in C++...
Write an assembly program for the MSP430 to calculate the number of zeros and ones in...
Write an assembly program for the MSP430 to calculate the number of zeros and ones in an array. If the number of zeros is more than the number of ones, the red LED(connected to P1.0 on the MSP430 launchpad) will turn on. Otherwise, the green LED (connected to P1.6 on the MSP430 launchpad) will turn on.
Write a Java program called RevenueAdvanced to calculate the revenue from a sale based on the...
Write a Java program called RevenueAdvanced to calculate the revenue from a sale based on the unit price and quantity of a product input by the user. (use if and if-else statements) • The discount rate is o 0% for the quantity purchased between 1 and 49 units. o 10% for the quantity purchased between 50 and 99 units. o 15% for the quantity purchased between 100 and 149 units. o 25% for the quantity purchased greater than or equal150...
In java Write a program called FileProcessor.java that reads the file numbers.txt, and: Calculate the total...
In java Write a program called FileProcessor.java that reads the file numbers.txt, and: Calculate the total number of numbers in the file, Calculate the sum of all the numbers in the file, Calculate the average of all the numbers in the file, Find the smallest value of all the numbers in the file, Find the largest value of all the numbers in the file, Calculate the standard deviation of all the numbers in the file
Using Matlab Write a function, called digits_function that is able to calculate the number of digits...
Using Matlab Write a function, called digits_function that is able to calculate the number of digits and the multiplication of the digits. The input of this function is N (entered number) and the outputs are number_digits and sum_digits.
You will write a PHP program to calculate the payment receipt for renting a number of...
You will write a PHP program to calculate the payment receipt for renting a number of movies, using a conditional structure. Suppose that the rental rate depends on the number of movies rented by a customer at a time. There is a limit of renting a maximum of 20 movies at a time. Conditions: For the first 2 movies rented, the rate is $5.50/movie. For the next 2 movies rented, the rate is $4.25/movie. For the next 3 movies rented,...
The wage at which exactly the desired number of workers is employed is called the: market-wage...
The wage at which exactly the desired number of workers is employed is called the: market-wage price market-compensation price market-clearing price market-balance price
Problem: Grading Function #Write a function called getScore() that does not take any parameter. Inside the...
Problem: Grading Function #Write a function called getScore() that does not take any parameter. Inside the function, it asks the user to input scores for 3 items (Each of the items is out of 100). The final score is calculated by 20% of item1 + 30% of item2 + 50% of item3. After calculating the final score, the function returns it to the caller. The scores are floating-point numbers. #Write another function called getLetterGrade() that takes a float parameter and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT