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