JAVA Help Objective: For this assignment, you will demonstrate that you can prop
ID: 3587258 • Letter: J
Question
JAVA Help
Objective: For this assignment, you will demonstrate that you can properly manipulate Java's built-in Scanner class, perform a variety of mathematical operations and data type conversions while using appropriate flow control and logical processing keywords to create a simple grade averaging program. Description: The ability to record user input and manipulate it mathematically is a frequent task in business computing. Business programmers will be entered by the user, therefore a frequently used skill is the ability to use flow control and logical operations to allow the user to enter however much data they need and to then signal the program to calculate by entering a special signal value. For this assignment, you will create a program that accepts an arbitrary number of grades (integer values) from the end user and when the user inputs the signal value (e.g. 999) to compute the average score and then also provide the letter often do not know ahead of time how much data ociated with the computed average. Assignment: Create a command-line Java class that performs the following Accepts an arbitrary number of grades from the user until the user enters a special signal value (e.g. 999) o You must use the Scanner class and read the values as a proper data type with an appropriate prompt * *Helpful tip: You should first check each entry to determine if the user entered the special signal value, if so make sure not to include the signal value into the calculated average Helpful tip: One way to solve this problem is to use a running tally which is simply the total of all values entered by the user, you may also find it helpful to maintain a counter that keeps track of how many times the loop has executed indicating how many grades the user has entered * The final grade can then be calculated as the running tally divided by the counter, make sure to provide this result as a decimal value *Helpful tip: Refer to pages 231 & 232 in your text for an example that is . very similar to portions of this assignment o Once the user has entered the special signal value Correctly calculate the average of all entered grades as a decimal value Output this average to the user Output the appropriate letter grade associated with the average to the user * o See Table 1 below for example prompts, user interaction and output Upload your .JAVA code file(s) to the appropriate Blackboard assignment Please enter the student's grade as a whole number (e.g. 83) (enter a grade of 999 to exit): 76Explanation / Answer
AverageAndGrade.java
import java.util.Scanner;
public class AverageAndGrade {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Please enter the student's grade as a whole number (999 to exit): ");
int grade = scan.nextInt();
int count = 0;
int sum = 0;
while(grade != 999) {
sum = sum + grade;
count++;
System.out.println("Please enter the student's grade as a whole number (999 to exit): ");
grade = scan.nextInt();
}
double average = sum/(double)count;
System.out.println("The student average grade is "+average);
char letterGrade='F';
if(average>=90){
letterGrade='A';
}
else if(average>=80 && average<90){
average='B';
}
else if(average>=70 && average<80){
letterGrade='C';
}
else if(average>=60 && average<70){
letterGrade='D';
}
else {
letterGrade='F';
}
System.out.println("Letter Grade is "+letterGrade);
}
}
Output:
Please enter the student's grade as a whole number (999 to exit):
75
Please enter the student's grade as a whole number (999 to exit):
76
Please enter the student's grade as a whole number (999 to exit):
77
Please enter the student's grade as a whole number (999 to exit):
999
The student average grade is 76.0
Letter Grade is C
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.