Java Program Suppose a student was taking 5 different course

Java Program

Suppose a student was taking 5 different courses last semester. Write a program that

(a) asks the student to input his/her name, student ID, marks for these 5 courses,

(b) calculate the average,

(c) determine the letter grade of each course.

(d) record the number of courses whose final letter grade is A+, A, A-, .... , F+, F, F-.

(e) Output the following information in a nice format: student name, student ID, listing of marks, the average, letter grade for each course, and the number of courses in each letter grade category.

I dont know how to do part c and d

here is the my code:

import java.util.Scanner;

public class Question_2 {

   public static void main(String[] args) {

      

       //declare variables

       String name;//student name

       int studentID;//student ID

       int mark1,mark2,mark3,mark4,mark5;//student marks in each 5 courses

      

       //asks the student to input his/her name

       System.out.println(\"Input your first name: \");

       Scanner input = new Scanner(System.in);

       name=input.nextLine();

      

       //asks the student to input student ID

       System.out.println(\"Input your StudentID (integer in 5 digits),ex:000000 :\");

       studentID=input.nextInt();

       //asks the student to input marks of 5 different courses last semester

       System.out.println(\"Input your courses grade (0-100)integer number \");

       System.out.println(\"Your course1\'s grade: \");

       mark1=input.nextInt();

       System.out.println(\"Your course2\'s grade: \");

       mark2=input.nextInt();

       System.out.println(\"Your course3\'s grade: \");

       mark3=input.nextInt();

       System.out.println(\"Your course4\'s grade: \");

       mark4=input.nextInt();

       System.out.println(\"Your course5\'s grade: \");

       mark5=input.nextInt();

      

       //Calculate the average of 5 different courses last semester

       double average = (mark1+mark2+mark3+mark4+mark5)/5.0;

      

       /*

       * Output the following information in a nice format: student name,

       * student ID, listing of marks, the average, letter grade for each

       * course, and the number of courses in each letter grade category.

       */

       System.out.println(\"**********************************************\");

       System.out.println(\"Student Name: \" + name);

       System.out.println(\"Student ID : \" + studentID);

       System.out.println(name+\" grade in \" + \"Course1: \"+mark1);

       System.out.println(name+\" grade in \" + \"Course2: \"+mark2);

       System.out.println(name+\" grade in \" + \"Course3: \"+mark3);

       System.out.println(name+\" grade in \" + \"Course4: \"+mark4);

       System.out.println(name+\" grade in \" + \"Course5: \"+mark5);

       System.out.println(name+\" avaerage grade is: \"+average);

       System.out.println(\"**********************************************\");

   }

}

Solution

For part c, you should have information regarding what is the corresponding grade for mark i.e. for 85 marks grade should be A-.

Once you have this information, you can make a separate method which passes marks in the corresponding course and with the information collected above return the grades like

if(marks>95)

return \'a\';

for part d, you need to make an array that keeps track of the frequency of each grade received. Index of the array will work as grade. For example, index 0 will be correspond to A+, index 1 will be correspond to A and so on.

So now, if suppose course 1 has grade A+ then we must increment the value in the array by 1 like grade[0]++;

And then we can print the frequency of the grade which have the frequency greater than that of 0.

Hope it helps. Feel free to comment in case of any query.

Java Program Suppose a student was taking 5 different courses last semester. Write a program that (a) asks the student to input his/her name, student ID, marks
Java Program Suppose a student was taking 5 different courses last semester. Write a program that (a) asks the student to input his/her name, student ID, marks
Java Program Suppose a student was taking 5 different courses last semester. Write a program that (a) asks the student to input his/her name, student ID, marks

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site