Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have the following JAVA program given to me and was asked to complete steps 1-4. I have done steps 1, 2 and 3 but

I have the following JAVA program given to me and was asked to complete steps 1-4. I have done steps 1, 2 and 3 but need help finishing step 4!

import java.util.Scanner; import java.text.DecimalFormat; public class TestAverageAndGrade{ public static void main(String[] args) { double score1, score2, score3, score4, score5; double average; // The average test score Scanner keyboard = new Scanner(System.in); DecimalFormat fmt = new DecimalFormat("0.00"); System.out.print("Enter five test scores: "); score1 = keyboard.nextDouble(); score2 = keyboard.nextDouble(); score3 = keyboard.nextDouble(); score4 = keyboard.nextDouble(); score5 = keyboard.nextDouble(); //step3: Call the method caclAverage to get the average, //and print it average = calcAverage(score1,score2,score3,score4,score5); System.out.println("Average is " +average); //step4: call the method determineGrade and print the grade for average grade = determineGrade{ }// end of main method /*step1: The calcAverage method calculates the average of five test scores.*/ public static double calcAverage(double s1, double s2, double s3, double s4, double s5) {double average = (s1+s2+s3+s4+s5)/5.0; return average;} /*step2: The determineGrade method determines the letter grade for a numeric test score.*/ public static char determineGrade(double a) {char grade; if(a>=90) grade='A'; else if(a>=80) grade='B'; else if(a>=70) grade='C'; else if(a>=60) grade='D'; else grade='F'; return grade;}

} //end of class TestAverageAndGrade

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions