Question

Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

Java Program:

In this project, you will 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: Your program will be graded on a ten-point scale. Your program is expected to have comments. Try to match your output with the same run. Submission: Upload your solution to assignment 1 in blackboard. Sample Run: Welcome to GradeCalculator!

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

---------------------------------------- Enter student 1’s name : Sample Name Enter exam scores : 90 100 -80 Invalid exam scores, reenter: 90 100 80

Grade statistics for Sample Name Average : 90 Letter grade: A Sample Name gets 4 stars! ****

---------------------------------------- Enter student 2’s name: Another Name Enter exam scores: 80 95 70

Grade statistics for Another Name Average : 81.66 Letter grade: C Another Name gets 2 stars! **

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

Done. Good bye!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
public class Main
{
public static char getgrade(double score)
{
if(score>=90&&score<=100)
return 'A';
else if(score>=80&&score<90)
return 'B';
else if(score>=70&&score<80)
return 'C';
else if(score>=60&&score<70)
return 'D';
else
return 'F';
}
public static String getstars(char grade)
{
if(grade=='A')
return " gets 4 stars!****";
else if(grade=='B')
return " gets 3 stars!***";
else if(grade=='C')
return " gets 2 stars!**";
else if(grade=='D')
return " gets 1 star!*";
else
return " No Stars for F grade";
}
   public static void main(String[] args)
   {
   int num_students,num_exams;
   String name;
   char letter_grade;
   char class_grade;
   Scanner s = new Scanner(System.in);
       System.out.println("Welcome to GradeCalculator!");
       System.out.println("Please enter the number of students: ");
       num_students=s.nextInt();
       System.out.println("Please enter the number of exams: ");
       num_exams=s.nextInt();
       double score,student_average=0,class_average=0,student_lowest,student_highest,class_lowest=101,class_highest=0;
       for(int i=0;i<num_students;i++)
       {
       student_average=0;
       student_lowest=101;
       student_highest=0;
       System.out.println("Enter student "+(i+1)+"’s name : ");
       name=s.nextLine();
       name=s.nextLine();
       System.out.println("Enter exam scores : ");
       for(int j=0;j<num_exams;j++)
       {
score= s.nextDouble();
while(score<0||score>100)
{
System.out.println("Invalid exam scores, reenter: ");
score= s.nextDouble();
}
if(score<student_lowest)
student_lowest=score;
if(score>student_highest)
student_highest=score;
student_average=student_average+score;
       }
       student_average=student_average/num_exams;
       class_average=class_average+student_average;
       System.out.println("Grade statistics for "+name+" Average: "+student_average+" Student Lowest: "+student_lowest+" Student Highest: "+student_highest+" Letter Grade: "+getgrade(student_average)+" "+name+getstars(getgrade(student_average)));
       if(student_average<class_lowest)
       class_lowest=student_average;
       if(student_average>class_highest)
       class_highest=student_average;
       }
       class_average=class_average/num_students;
       System.out.println("Class statistics: Average: "+class_average+" Lowest: "+class_lowest+" Highest: "+class_highest+" Grade: "+getgrade(class_average)+" Class: "+getstars(getgrade(class_average)));
   }
}

Add a comment
Know the answer?
Add Answer to:
Java Program: In this project, you will write a program called GradeCalculator that will calculate the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1...

    Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1 to the Office of Registrar at the end of the semester. Display an introductory paragraph for the user then prompt the user to enter a student record (student ID number and five exam-scores – all on one line). The scores will be in the range of 0-100. The sentinel value of -1 will be used to mark the end of data. The instructor has...

  • Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and...

    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 complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • in C++ Create a program that will calculate a student’s grade average of 5 test scores...

    in C++ Create a program that will calculate a student’s grade average of 5 test scores and assign a letter grade for a student. The program should use a class to store the student’s data including the student’s name and score on each of 5 tests. The program should include member functions to 1) get the student’s test scores, 2) calculate the average of the test scores, and 3) display the results as follows: Test scores for Mary: 100 90...

  • C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade...

    C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade is determined by first calculating her weighted average as follows:                                                 (score1 + score2 + score3 + score4 + max_score) weighted_average = -----------------------------------------------------------------------                                                                                                 5 This counts her maximum score twice as much as each of the other scores. Her letter grade is then a A if weighted average is at least 90, a B if weighted average is at least 80...

  • Write a Java program that reads a file until the end of the file is encountered....

    Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...

  • Create a C++ program to calculate grades as well as descriptive statistics for a set of...

    Create a C++ program to calculate grades as well as descriptive statistics for a set of test scores. The test scores can be entered via a user prompt or through an external file. For each student, you need to provide a student name (string) and a test score (float). The program will do the followings: Assign a grade (A, B, C, D, or F) based on a student’s test score. Display the grade roster as shown below: Name      Test Score    ...

  • SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes...

    SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array....

  • Write python code on computer, No handwritten code You will implement a program which asks the...

    Write python code on computer, No handwritten code You will implement a program which asks the user to enter scores of different courses in different semesters. The program should read the input and output some simple statistics 1. An example input string by the user is given below. Fal12016-coursel:82, course2:80,course3:85;Spring2018- course4:82;Fall2018-course5:85, course6:50, course7:78 Info from different semesters are separated by a ";", courses in each semester are separated by a,and score and corresponding course is separated by a, information of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT