Ask Question
30 April, 11:09

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. 30 April, 11:28
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers