Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the Java application by writing the code segments that will complete this if-else-while-problem. Problem Solving Process is not necessary. You have 15 minutes. import

Complete the Java application by writing the code segments that will complete this if-else-while-problem. Problem Solving Process is not necessary. You have 15 minutes.

import java.util.Scanner; // class uses class Scanner

public class MyGrades1

{

public static void main(String[] args)

{

Scanner input = new Scanner( System.in );

System.out.print( "Enter grade 1-100: " );

studentGrade = input.nextInt();

while (studentGrade >= 0)

{

if (studentGrade >= 90)

{

System.out.println("A");

++countGrade;

}

else if (studentGrade >= 80)

{

System.out.println("B");

++countGrade;

}

else if (studentGrade >= 70)

{

System.out.println("C");

++countGrade;

}

else if (studentGrade >= 60)

{

System.out.println("D");

++countGrade;

}

else

{

System.out.println("F");

++countGrade;

}

}//end of while loop

System.out.printf("The average of these %d grades is: %5.2f ",

countGrade, avgGrade = totalGrade/countGrade);

}//end main

}// end class

SAMPLE OUTPUT:

Enter grade 1-100: 100

A

Enter grade 1-100: 75

C

Enter grade 1-100: 50

F

Enter grade 1-100: -1

The average of these 3 grades is: 75.00

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

More Books

Students also viewed these Databases questions

Question

Outlining Your Speech?

Answered: 1 week ago