omarion83 omarion83
  • 02-04-2022
  • Computers and Technology
contestada


Write a program that asks the user to type 5 integers
and writes the average of the 5 integers. This
program can use only 2 variables.

Respuesta :

nunoz
nunoz nunoz
  • 03-04-2022

import Java.util*

public class Average{
public static void main(String [] args){

int sum = 0;
int numbers = 0;

for(int i = 0; i < 5; i++){
Scanner sc = new Scanner(System.in);
System.out.println(“Please enter your integers: “);
numbers = sc.nextInt();

sum += numbers;
}
System.out.println(“The average is: “ + sum/5)”
}
}
Answer Link

Otras preguntas

Write 0.00085 in standard form
Describe how insulation works and the role it plays in keeping our homes at a comfortable temperature.
Should secret wiretapping be legal
how do landforms affect human life
How do environmental factors affect diffusion rates?
What is mercantilism? A. an economic policy that relies on a ruling government to increase the wealth of a nation by controlling trade B. a political policy tha
A bus travels 20 km in 30 minutes. what is the average speed of the bus?
Find the unit rate of 135 miles in 5 hours
A recipe that makes 6 servings calls for 1/2 cup of butter. Nancy modifies the recipe so that it can serve 8 How many cups of butter does Nancy need?
Anne was observing a cell under a microscope which was undergoing binary fission. Which type of cell was Anne observing? 1 Eukaryotic animal cell 2 Eukaryotic p