Question

In: Computer Science

Write a program that asks the user to enter five test scores. The program should display...

Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program:

calcAverage:
This method should accept five test scores as arguments and return the average of the scores.

determineGrade:
This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale:

Score Letter Grade
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F

Sample Run
java TestAvgAndGrade

·Enter·test·grade·for·student·1:55↵
·Enter·test·grade·for·student·2:65↵
·Enter·test·grade·for·student·3:75↵
·Enter·test·grade·for·student·4:85↵
·Enter·test·grade·for·student·5:95↵
·The·letter·grades·are·as·follows:↵
Student·1:·F↵
Student·2:·D↵
Student·3:·C↵
Student·4:·B↵
Student·5:·A↵
The·average·grade·was:·75.00↵

Solutions

Expert Solution

import java.util.*;
public class Main{
public void calcAverage(int b[]){
int j,temp=0;
for(j=0;j<b.length;j++){
temp+=b[j];
}
temp=temp/5;
System.out.print("The·average·grade·was:·");
System.out.print(temp);
}
public void determineGrade(int c[]){
int k;
for(k=0;k<c.length;k++){
if(c[k]>=90&&c[k]<=100){
System.out.println("Student·1:·A↵");
}
else if(c[k]>=80&&c[k]<=89){
System.out.println("Student·1:·B↵");
}
else if(c[k]>=70&&c[k]<=79){
System.out.println("Student·1:·C↵");
}
else if(c[k]>=60&&c[k]<=69){
System.out.println("Student·1:·D↵");
}
else if(c[k]<=60){
System.out.println("Student·1:·F↵");
}
}
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=5;
int a[]=new int[n];
for(int i=1;i<=5;i++){
System.out.print("\nEnter.test.grade.for.student.");
System.out.print(i);
System.out.print(":");
a[i-1]=sc.nextInt();
}
Main obj=new Main();
obj.determineGrade(a);
obj.calcAverage(a);
}
}

OUTPUT:


Related Solutions

Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
Program should be written in Java a) Write a program that asks the user to enter...
Program should be written in Java a) Write a program that asks the user to enter the approximate current population of India. You should have the computer output a prompt and then YOU (as the user should enter the population.)  For testing purposes you may use the value of 1,382,000,000 from August 2020. Assume that the growth rate is 1.1% per year. Predict and print the predicted population for 2021 and 2022. The printout should include the year and the estimated...
Write a javascript program that asks the user to enter up to 10 golf scores, which...
Write a javascript program that asks the user to enter up to 10 golf scores, which are to be stored in an array. You should provide a means for the user to terminate input prior to entering 10 scores. The program should display all the scores on one line and report the average score. Handle input, display, and the average calculation with three separate array processing functions.
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
Write a class that asks a user to enter three integers. Display them in ascending and...
Write a class that asks a user to enter three integers. Display them in ascending and descending order. Save the file as Sorting.java Again, Don’t forget to create the application/project  SortingTest.java Class that has the main method and an object to use the Sorting class.
Write a Java program that asks the user to enter an integer that is used to...
Write a Java program that asks the user to enter an integer that is used to set a limit that will generate the following four patterns of multiples of five using nested loops •Ascending multiples of five with ascending length triangle •Ascending multiples of five with descending length (inverted) triangle •Descending multiples of five with ascending length triangle •Descending multiples of five with descending length (inverted) triangle Use error checking to keep asking the user for a positive number until...
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Write a program that asks the user to enter an unsigned number and read it. Then...
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6. COMMENT COMPLETE CODE PLEASE
In a file called LengthSum.java, write a program that: - Asks the user to enter a...
In a file called LengthSum.java, write a program that: - Asks the user to enter a string. - Asks the user to enter a second string. - Prints out the length of the first string, the length of the second string, and the sum of the two lengths, using EXACTLY the same format as shown below. For example: if the user enters strings "UT" and "Arlington", your program output should look EXACTLY like this: Please enter a string: UT Please...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT