Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions package edu.buffalostate.cis 4 2 5 . sp 2 4 . put - your - username - here; / * * * File: Average.java *

Instructions
package edu.buffalostate.cis425.sp24.put-your-username-here;
/**
* File: Average.java
*
* Requirements
*
* Write a program that accepts 10 integers from the keyboard and
* computes their average.
* if the user enters 9999, the program exits early, and outputs
* the average of the numbers entered so far.
*
* Fill in the blanks to make the program work
*
*/
/**
*
* @author put-your-name-here
*
*/
import java.util.Scanner;
public class Average {
public static void main( String args[]){
double ave =0.0, num =0.0, sum =0.0;
int cnt =0;
Scanner sc = new _____________;
System.out.println( "Integer Averaging Program" );
System.out.println( "Enter 10 Integers" );
// add a line here to output a message advising the user to enter 9999 to exit
for (______________){
System.out.print("Enter Integer "+ i +": ");
// check if the user entered a non-integer
if (!sc.hasNextInt()){
// System.err will print the message in RED
System.err.println("Sorry, please enter an integer");
sc.nextLine();
i--;
continue;
}
num = sc.nextInt();
if (num ==9999){
__________
}
cnt++;
sum = sum + num;
}
if (_____________){
ave =_____________;
} else {
____________;
}
System.out.println("The average of "+ cnt +" numbers is "+ ave );
}// end main
}// end Average
When you have this Exercise ready for me to view and grade, you should upload your Average.java file here.

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_2

Step: 3

blur-text-image_3

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