Ask Question
4 June, 07:08

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

+1
Answers (1)
  1. 4 June, 08:26
    0
    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));
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given the following code fragment and the input value of 4.0, what output is generated? double tax; double total; System. out. print ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers