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 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:...
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.
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...
Write a c program to calculate the factorial of a number using recursion    [8] Question five...
Write a c program to calculate the factorial of a number using recursion    [8] Question five Write a stack algorithm to POP an item                                                         [6] What does FRONT and REAR signify in a queue?                                                                 [6] Write an algorithm for a dequeue operation                                                                       [8]
Write a program that utilizes a function called paymentCalc. In the main body of the program,...
Write a program that utilizes a function called paymentCalc. In the main body of the program, ask the user what is their principal and how many months they want the loan. If it is easier, ask the user for number of years, but don’t forget to change it to months for the calculation. Use a function to calculate their monthly mortgage payment. In the main body of the program, print out what their monthly mortgage payment will be. For simplicity,...
(Write a program in C++) A local instructor wants you to write a program to calculate...
(Write a program in C++) A local instructor wants you to write a program to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT