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

Why did female factory workers like Charlotte Woodward support the women’s rights movement?
placing 12 tiles side by side, Pete can make a 12-by-1 rectangle. Name two other rectangles Pete can make with 12 tiles
what is the value for the expression -5+ 5
A box is lowered using a rope. If the acceleration of the box, is 2.5 m/s2 (downward) and the tension in the rope is 31 N, what is the mass of the box (in kg)?
placing 12 tiles side by side, Pete can make a 12-by-1 rectangle. Name two other rectangles Pete can make with 12 tiles
What Was Jackson’s perspective on the McCulloch v. Maryland Supreme Court Case
wallpaper cost $2 per square yard how much would it cost to cover a rectangular wall that measures 15 feet by 21 feet
What's 45 out of 58 in percentage?
16x^2-24x+7=0 equation and/or inequalities
In 1940 What was Germany’s initial strategy for conquering Britain?