Question: What will be the output if the input values are 5 , 1 0 , 2 , 1 0 , and 5 ? public static

What will be the output if the input values are 5,10,2,10, and 5?
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
double grade, avg, total =0;
for (int i =1; i <=5; i++){
System.out.print("Enter age "+i+" : ");
grade = sc.nextDouble();
total += grade;
}
System.out.println("Average age: "+(total /5));
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!