Multiple Choice
What will be the final output of the following code snippet when a user enters input values in the order 10, 20, 30, 40, 50, and -1? public static void main(String[] args)
{
Double sum = 0;
Int count = 0;
Double salary = 0;
Double average = 0;
Scanner reader = new Scanner(System.in) ;
System.out.println("Enter salaries (-1 to stop) : ") ;
While (salary != -1)
{
Salary = reader.nextInt() ;
If (salary != -1)
{
Sum = sum + salary;
Count++;
}
}
If (count > 0)
{
Average = sum / count;
System.out.println("The Average Salary: " + average) ;
}
Else
{
System.out.println ("No data!") ;
}
Return 0;
}
A) The Average Salary: 0
B) The Average Salary: 30
C) The Average Salary: 24.83333
D) There will be no output as the code snippet will not compile.
Correct Answer:

Verified
Correct Answer:
Verified
Q113: What is the outcome of the following
Q114: What is the output of the code
Q115: What are the values of i and
Q116: Insert a statement that will correctly terminate
Q117: Which of the following conditions can be
Q119: Which of the following loop(s) should be
Q120: How many times will the output line
Q121: What is the output of the code
Q122: What is the output of the code
Q123: Which loop does not check a condition