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

Can you give examples of carbon in our living environment?
Are the given lengths 24, 60, 66, sides of a right triangle?
Why does photosynthesis require water? a. because water provides oxygen atoms b. because water provides electrons c. because water accepts electrons d. because
Which of the following is true of a human karyotype? A. Each cell has 22 pairs of homologous chromosomes B. Each cell has one pair of sex chromosomes C. The chr
how to write a word problem
Can you give examples of carbon in our nonliving environment?
which dispute with Britain was settled in 1846
Jaiden is writing a report about the structure of the atom. In her report, she says that the atom has three main parts and two subatomic particles. Do you agree
Colonel George Washington led a militia force into the Ohio Valley in 1754. What was the name of the fort that Washington built and was near the site of the fir
Between which pair of numbers is the exact product of 379 and 8?