Write code segments in Java that reads 10 positive integers and output the sum and average of the numbers. For example, if the input is 13 19 9 32 70 5 42 2 33 62, then the output will be 287.0 and 28.7.
Answers
Answered by
0
import java.util.Scanner;
class Simple {
public static void main (String args[]){
Scanner scan = new Scanner(System.in);
int sum= 0;
for(int i=0;i<10;i++){
System.out.println("Enter "+(i+1)+"th number");
int temp= scan.nextInt();
sum+=(temp);
}
System.out.println(sum);
System.out.println(sum/10);
}
}
Similar questions
Math,
2 months ago
Computer Science,
2 months ago
Science,
2 months ago
Science,
5 months ago
Biology,
5 months ago
Political Science,
10 months ago
Physics,
10 months ago