Given the following code fragment and the input value of 4.0, what output is generated?
double tax;
double total;
System.out.print("Enter the cost of the item");
total = scan.nextDouble();
if ( total >= 3.0)
{

tax = 0.10;
System.out.println(total + (total * tax));
}
else
{
System.out.println(total);
}
(a)5
(b)4
(c)4.4
(d) 3



Respuesta :

Answer:

c) 4.4

Explanation:

You can evaluate step by step the code. You know tha your input is 4.0

Step 1 Variables definitions:

double tax;

double total;

Step 2 Ask the user for the input:

System.out.print("Enter the cost of the item");

Step 3 read de input:

total = scan.nextDouble();

Step 4 evaluate the condition (  is the input greater or equal  than 3.0 ? [True])

if ( total >= 3.0)

Step 5 get done the operations inside the condition and print it:

tax = 0.10;

System.out.println(total + (total * tax));