Java script The Grade Average Program Requirements: You will create the pseudo-c
ID: 652842 • Letter: J
Question
Java script
The Grade Average Program Requirements:
You will create the pseudo-code and Java Script program which will prompt the user for four (4) numeric grades.
Requirements:
Use an array to store the grades.
Use a looping structure to populate the array.
Calculate the numeric average based upon the 4 equally-weighted numeric grades.
Display each of the 4 numeric grades from the array on the screen using a looping structure.
Display the numeric average.
Create a function that will convert the numeric average to a letter grade average using the grading scale:
A = 90 to100
B = 80 to 89
C = 70 to 79
D = 60 to 69
F = Below 59
The function must return the value of the letter grade average.
Display the letter grade average.
Include comments
Explanation / Answer
import java.io.*;
public class Avg1 {
public static void main(String[] args) {
int n = 5,avg0;
int marks[] = {65,80,75,90,60};
avg0= (marks[0]+marks[1]+marks[2]+marks[3]+marks[4]) / n;
int avg[];
avg=new int[1];
avg[0]=avg0;
System.out.println("Mark1=" +marks[0]+" Mark2="+marks
[1]+" Mark3="+marks[2]+" Mark4="+marks[3]+" Mark5="+marks[4]);
System.out.println("Average of Marks="+avg[0]);
//getGrade(avg[0]);
System.out.println("Grade="+getGrade(avg0));
}
public static String getGrade(String avg0)
{
char grade;
if((avg0> 90) && (avg0<= 100))
grade = 'A';
else if ((avg0> 80) && (avg0<= 90))
grade = 'B';
else if ((avg0> 70) && (avg0<= 80))
grade = 'C';
else if ((avg0> 60) && (avg0<= 70))
grade = 'D';
else
grade = 'E';
return grade;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.