Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program has 2 parts. I already did the first one, I need help on Part 2. Pa

ID: 3630542 • Letter: T

Question

This program has 2 parts. I already did the first one, I need help on Part 2.

Part 1
Suppose you are asked to write a program for the world’s laziest grader.
Rather than properly grading and averaging all of a student’s exams to
determine an overall letter grade, this grader wants a program that will
randomly assign a letter grade based on whether or not the grader likes
the student.
Your program should prompt the grader to enter 1 if they like the student
or 0 if they do not. If the grader likes the student, your program should
randomly select either A, B, or C for the letter grade. If the grader does
not like the student, your program should randomly select either D or F.
After you have received the input from the grader, you must make a
method call to calculate the letter grade using the technique described
above (you may not perform the calculations inside of the main method)
and then print the returned letter grade. The method signature of the
method called inside of main must be:
public static char calculateGrade(boolean likesStudent)

1 import java.util.Scanner;
2 public class D7E1 {
3 public static void main(String[] args) {
4 String[] students = {"Chary", "Nathaniel", "Luis", "Ashley", "Kate", "Elizabeth", "Paulo"};
5 Scanner input = new Scanner(System.in);
6 for (int n = 0; n < students.length; n++) {
7 System.out.println(students[n]);
8 int i = input.nextInt();
9 switch(i) {
10 case 0: System.out.println(calculateGrade(false));
11 break;
12 case 1: System.out.println(calculateGrade(true));
13 break;
14 default:
15 }
16 }
17 }
18 public static char calculateGrade(boolean likesStudent){
19 int i = (int)(Math.random() * 3);
20 if (likesStudent == true) {
21 switch(i) {
22 case 2: return 'A';
23 case 1: return 'B';
24 case 0: return 'C';
25 }
26 }
27 else {
28 switch(i) {
29 case 0:
30 case 1: return 'D';
31 case 2: return 'F';
32 }
33 }
34 return 'Q';
35 }
36 }
~
Part 2.
Now that the grader has finished grading all three exams for the course, the
grader would like the option of computing the student’s grade fairly.
Your program should now prompt the grader to enter 1 if they would like to
grade fairly and 0 if they would like to use the previous method. If the
grader enters in 0 (to grade unfairly), ask the grader to enter 1 if they like
the student and 0 if they do not like the student, then call the same method
used in the previous exercise. If the grader entered 1 (to grade fairly),
prompt the grader to enter in each of the three exam scores, make a method
call to calculate the average of these three exams, and print the returned
letter grade (where 90 <= x <= 100 is an A, 80 <= x < 90 is a B, etc).
As in the previous problem, you may not perform any calculation inside of
the main method. The method signature for this new method must be:
public static char calculateGrade(double exam1,
double exam2, double exam3)

Explanation / Answer

please rate - thanks


import java.util.Scanner;
public class D7E1 {
public static void main(String[] args) {
String[] students = {"Chary", "Nathaniel", "Luis", "Ashley", "Kate", "Elizabeth", "Paulo"};
Scanner input = new Scanner(System.in);
int choice;
double g1,g2,g3;
System.out.print("Do you want to grade fairly(1=yes, 0=no)? ");
choice=input.nextInt();
if(choice==0)
    { for (int n = 0; n < students.length; n++) {
     System.out.println("Do you like "+ students[n]+"1=yes,0=no: ");
    int i = input.nextInt();
     switch(i) {
     case 0: System.out.println(calculateGrade(false));
     break;
     case 1: System.out.println(calculateGrade(true));
     break;
     default:
     }
}
}
else
{for (int n = 0; n < students.length; n++)
      {System.out.println("For "+students[n]);
        System.out.print("Enter grade 1: ");
        g1=input.nextDouble();
        System.out.print("Enter grade 2: ");
        g2=input.nextDouble();
       System.out.print("Enter grade 3: ");
        g3=input.nextDouble();
        System.out.println(calculateGrade(g1,g2,g3));
        }

       
    
}

}
public static char calculateGrade(boolean likesStudent){

int i = (int)(Math.random() * 3);
if (likesStudent == true) {
     switch(i) {
         case 2: return 'A';
case 1: return 'B';
case 0: return 'C';
}
}
else {
switch(i) {
case 0:
case 1: return 'D';
case 2: return 'F';
}
}
return 'Q';
}

public static char calculateGrade(double exam1,double exam2, double exam3)
{double average=(exam1+exam2+exam3)/3.;
if(average>=90)
     return 'A';
else if(average>=80)
     return 'B';
else if(average>=70)
     return 'C';
else if(average>=60)
     return 'D';
else
     return 'F';

   
}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote