Write a java application that calculates and prints sum and average of any 30 numbers .Use a do while statement to loop through the calculation
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int count = 30;
double sum = 0;
do {
sum += in.nextInt();
} while (--count > 0);
System.out.println("Sum: " + sum);
System.out.println("Average: " + sum / 30);
}
}
Comments
Leave a comment