Problem 3 Write a program to calculate your current grade based on the CSE 1341
ID: 3545030 • Letter: P
Question
Problem 3
Write a program to calculate your current grade based on the CSE 1341 syllabus. The program should prompt the user for their first and last name. It will then pass those names as Strings to the second method calcGrade of the CSE1341Grade class. The calcGrade will accept the two String references as input parameters and it will create arrays for each of the categories which would help determine the final grade. All the arrays must be initialized to a value of -1. Once all the arrays are created, the calcGrade method will invoke the 3rd method of this class named getScores. This new method will accept all the arrays created in calcGrade method as input parameters. For example, the getScores method may be passed an examArray, a quizArray, and a labArray to be populated with scores and this will totally depend upon your own instructor's syllabus for the course. The getScores method will prompt the user for the count of exam scores, count of quiz scores, and count of lab scores based on what has already been graded. The getScores method will utilize repetition structures to prompt the user to enter specific scores based on the count of each category provided and not the length of the arrays. Inside getScores method, create an arrays countArray to hold the counts of each of the categories provided by the user. The size of this array will be equal to the number of categories per the syllabus. The getScores method will return the countArray back to the calling method which will be utilized by the caller to calculate the current grade. The calcGrade method will utilize the specific arrays to calculate averages for each of the categories and apply the necessary weights based on your syllabus. Assume you have a 100% attendance record and you will get all 5% of the attendance grade if that is a category in your syllabus. Assume: all exams, labs and quiz scores are out of 100 points. Sample Run:Explanation / Answer
import java.util.Scanner;
public class CSE1341Grade
{
public static void main(String [] args)
{
//set up Scanner for user input, prompt for first name, define variable, and print response
Scanner s = new Scanner(System.in);
System.out.print("First name: ");
String first = s.nextLine();
System.out.printf(" %s ", first);
//prompt user for last name, define variable, and print response
System.out.print("Last name: ");
String last = s.nextLine();
System.out.printf(" %s ", last);
}
public static void calcGrade(String first, String last)
{
//prompt user for number of exam grades, define exam variable, print response
System.out.print("How many exam grades do you have? ");
String exam = s.nextLine();
System.out.printf(" %s ", exam);
//prompt user for number of quiz grades, define quiz variable, print response
System.out.print("How many quiz grades do you have? ");
String quiz = s.nextLine();
System.out.printf(" %s ", quiz);
//prompt user for number of lab grades, define lab variable, print response
System.out.print("How many lab grades do you have? ");
String lab = s.nextLine();
System.out.printf(" %s ", lab);
while (exam != -1)
{
System.out.print("Enter " exam 1 " score: ", ++exam)
//define variables for computations
int score = 0;
int grade = 0;
//if statement to determine the final letter grade
if(score >= 90 && score <=100){
grade = 'A'; }
else if(score >=80 && score < 90){
grade = 'B'; }
else if(score >= 70 && score < 80){
grade = 'C'; }
else if(score >=60 && score < 70){
grade = 'D'; }
else {
grade = 'F'; }
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.