Examlex

Solved

What Will Be the Final Output of the Following Code

question 64

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;
}


Definitions:

Cash Flow Calculator

A tool used to estimate the amount of cash generated and used by a business or individual in a specific time period.

Cash Flow

The total amount of money being transferred in and out of a business, especially as affecting liquidity.

Debt-to-Income Ratio

A financial metric that compares an individual's total monthly debt payments to their gross monthly income.

Annual Salary

The total amount of money an employee earns in one year before taxes and deductions.

Related Questions