Java CS 0007 Programming Assignment 4 Problem Write a program that asks the user
ID: 3683784 • Letter: J
Question
Java
CS 0007 Programming Assignment 4
Problem
Write a program that asks the user for the number of students in a class and the number of exams in the course, and then gets as input the student names and their scores on the exams. You should store these scores in a twodimensional array, and then compute and output the following:
Each student’s average on the exams.
The max and min scores earned for each exam.
The average student score for the entire course.
Example
3 students, 3 exams
Exam 1: Max 100, Min 78
Exam 2: Max 90, Min 88
Exam 3: Max 100, Min 92
Adam: Average 93.3
Betty: Average 88.7
Carl: Average 91 Class Average: 91
What to Submit
Your .java file.
Exam 1 Exam 2 Exam 3 Adam 100 88 92 Betty 78 88 100 Carl 89 90 94Explanation / Answer
import java.util.Scanner;
public class CaseGrade
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
String name ;
int grade;
String exellent = "Exellent :";
String Exam 1 ="Exam 1 :";
String Exam 2 ="Exam 2 :";
String Exam 3 ="Exam 3 :";
int max = 100,90,100;
int min = 78,88,92;
int avg = 93.3,88.7;
int counter =0;
boolean repeat ;
while (repeat =true)
{
System.out.println("Enter Name : ");
name = input.next();
System.out.println("Enter Grade : ");
grade = input.nextInt();
if (grade == -1 )
{
avg = sum / counter;
System.out.println(" result = :");
System.out.println(exellent +" "+ veryGgood +" "+ good +" "+ pass +" "+fail);
System.out.println("maximum = "+ max +" ");
System.out.println("minimum = "+ min +" ");
System.out.println(" Average = " +avg);
System.exit(0);
}
switch (grade/10)
{
case 100:
case 9 :
Exam 1 += " "+ name + " " +grade+" ";
break;
case 8 :
Exam 2+= " " + name + " " +grade +" ";
break ;
case 7 :
Exam 3+= " " + name + " " +grade +" ";
break;
pass += " " + name + " " +grade +" ";
break;
default:
fail +=" " + name + " " +grade +" ";
break;
}
sum = sum + grade;
counter = counter + 1;
if (grade > max)
{
max = grade;
}
if (grade < min)
{
min = grade;
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.