Question

Write a program that will calculate your letter grade at the end of the semester for...

Write a program that will calculate your letter grade at the end of the semester for CSIS130.

Your program will read an input file that shall contain all the tests scores and lab scores for the semester, and the input file data should be in the following format:

full name of student

Test1 Score (0…100),

Test2 Score (0..100) ,

Final Exam Score (0..100),

Total Number of Labs: N

NLab Scores (0=Fail, 1=Pass) [You will have N lab scores each separated by a blank

The program will then calculate 1:your average lab grade  from 100, 2: your final class numeric grade from 100 and the final class letter grade. The output will look like:

Student:  Full Name

Lab Numeric Grade: 0,…,100*

Course Numeric Grade: 0,..,100*

Course  Letter Grade: A,…,F*

Grades are distributed as follows:

LabsPercentage: 20%

Test1Percentage: 20%

Test2Percentage: 20%

FinalExamPercentage: 40%

Letter Grade Distribution is as follows:

A:94-100       A-:90-93

B+:87-89            B:84-86          B-:80-83

C+:77-79            C:74-76         C-:70-73

D+:67-69            D:64-66         D-:60-63

F:0-59                 FN:0-59

*To calculate Lab numeric grade: sum all lab scores then divide by total number of labs, then multiply by 100.

* To calculate Course Numeric grade:

NumericScore=

Test1* Test1Percentage  + Test2*Test2Percentage  + FinalExam* FinalExamPercentage + LabNumericGrade* LabsPercentage

Note, While reading the data from the input file the program must not crash, rather your program must catch the following exceptions

If  FileNotFoundException, incase user enters a wrong file name to read from

Program display message wrong file and loops back to ask for the proper filename

If InputMismatchException, incase you where expecting a certain type o finput but read a different type then Print a message wrong data type read , then Print program will terminate, then end the program with System.exit(0);

Example:  Input to file:

Enter file Name: my130grades.txt

[my130grades.txt  data ]

Mariam Aron

70

85

90

4

1

1

1

0

Output of program, for the above input:

Student: Mariam Aron

Lab Numeric Grade: 75

Course Numeric Grade: 82.80

Course Letter Grade: B-

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

Program:

//importing required classes
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

//defining class
public class LetterGrade {
    //defining main method
    public static void main(String[] args) throws IOException {
        //variables
        int test1=0,test2=0,finalExam=0,lab[],labsum=0;
        double labNumericGrade=0,numericScore,labsPercentage=0.2,test1Percentage=0.2,test2Percentage=0.2,finalExamPercentage=0.4;
        String name="",file,val,letterGrade="";
        BufferedReader br;
        FileReader fr;
        boolean error;
        //asking for user input
        Scanner input=new Scanner(System.in);
        do{
            error=false;
        System.out.print("Enter the file name: ");
        file=input.nextLine();
        try{
            fr=new FileReader(file);
            br=new BufferedReader(fr);
        //reading data from file
        while((val=br.readLine())!=null){
            name=val;
            test1=Integer.parseInt(br.readLine());
            test2=Integer.parseInt(br.readLine());
            finalExam=Integer.parseInt(br.readLine());
            lab=new int[Integer.parseInt(br.readLine())];
            for(int i=0;i<lab.length;i++){
                lab[i]=Integer.parseInt(br.readLine());
                labsum=labsum+lab[i];
            }
            //calculating the grrades
            labNumericGrade=(labsum*100/lab.length);
            numericScore=test1* test1Percentage + test2*test2Percentage + finalExam* finalExamPercentage + labNumericGrade* labsPercentage;
            if(numericScore>=94){
                letterGrade="A";
            }
            else if(numericScore<94 && numericScore>=90){
                letterGrade="A-";
            }
            else if(numericScore<90 && numericScore>=87){
                letterGrade="B+";
            }
            else if(numericScore<87 && numericScore>=84){
                letterGrade="B";
            }
            else if(numericScore<84 && numericScore>=80){
                letterGrade="B-";
            }
            else if(numericScore<80 && numericScore>=77){
                letterGrade="C+";
            }
            else if(numericScore<77 && numericScore>=74){
                letterGrade="C";
            }
            else if(numericScore<74 && numericScore>=70){
                letterGrade="C-";
            }
            else if(numericScore<70 && numericScore>=67){
                letterGrade="D+";
            }
            else if(numericScore<67 && numericScore>=64){
                letterGrade="D";
            }
            else if(numericScore<64 && numericScore>=60){
                letterGrade="D-";
            }
            else if(numericScore<60 && numericScore>=50){
                letterGrade="F";
            }
            else {
                letterGrade="FN";
            }
            //printing the details
            System.out.println("Student: "+name);
            System.out.println("Lab Numeric Grade: "+labNumericGrade);
            System.out.println("Course Numeric Grade: "+numericScore);
            System.out.println("Course Letter Grade: "+letterGrade);
        }
        }
        catch(FileNotFoundException fn){
            error=true;
        }
        //repeating for wrong user input
        }while(error=true);
    }
}

Output:

Add a comment
Know the answer?
Add Answer to:
Write a program that will calculate your letter grade at the end of the semester for...
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
  • Write a program to calculate your final grade in this class. Three(8) assignments have yet to...

    Write a program to calculate your final grade in this class. Three(8) assignments have yet to be graded: Quiz 7, Lab 7 and Final Project. Assume ungraded items receive a grade of 100 points. Remember to drop the lowest two quiz scores. Display final numeric score and letter grade. Implementation: Weight distribution is listed in canvas. Use arrays for quizzes, labs, projects and exams. You are allowed to use initialization lists for arrays. Use at least three (3) programmer defined...

  • C++ Write a program to calculate final grade in this class, for the scores given below...

    C++ Write a program to calculate final grade in this class, for the scores given below . Remember to exclude one lowest quiz score out of the 4 while initializing the array. Display final numeric score and letter grade. Use standard include <iostream> Implementation: Use arrays for quizzes, labs, projects and exams. Follow Sample Output for formatting. May use initialization lists for arrays. Weight distribution is as follows: Labs: 15% Projects: 20% Quizzes: 20% Exams: 25% Final Project: 20% Display...

  • 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...

  • 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...

  • Write a grading program for the following grading policies:- a. There are two quizzes, each graded...

    Write a grading program for the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:- >90 A >=80 and <90 B...

  • 1. Create a program that takes a numerical score and outputs a letter grade. 2. In...

    1. Create a program that takes a numerical score and outputs a letter grade. 2. In this program, create two void functions titled makeScore and theGrade with an int argument. 3. The function makeScore should have a Reference parameter and theGrade should have a Value parameter. Note: Specific numerical scores and letter grades are listed below: 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F 4. The function makeScore...

  • C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to...

    C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to include the following: •   Write a Search function to search by student score •   Write a Search function to search by student last name •   Write a Sort function to sort the list by student score •   Write a Sort function to sort the list by student last name •   Write a menu function that lets user to choose any action he/she want to...

  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

  • 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...

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