Computer science java programming
Question Description
3. The following program reads three integers and prints the average. Fill in the blanks so that it will work correctly.
import java.util.Scanner;
public class Average
{
public static void main(String[] args)
{
int val1, val2, val3;
double average;
Scanner scan = new Scanner(System.in);
val1 = scan.nextInt(); // get three values from user
val2 = scan.nextInt();
val3 = scan.nextInt();
System.out.println(“Please enter three integers and ” +
“I will compute their average”);
average = (val1 + val2 + val3) / 3; //compute the average
System.out.println(“Average is ” + average); //print the average
}
}
Get your college paper done by experts
Do my question How much will it cost?Place an order in 3 easy steps. Takes less than 5 mins.
Leave a Reply
Want to join the discussion?Feel free to contribute!