112k views
1 vote
What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 1250; char cust = 'N'; if (purchase > 1000) if (cust == 'Y') discountRate = 0.05; else discountRate = 0.04; else if (purchase > 750) if (cust == 'Y') discountRate = 0.04; else discountRate = 0.03; else discountRate = 0.0;

User Duray
by
4.1k points

1 Answer

2 votes

Answer:

The question is incomplete, the options include:

a. 0.03

b. 0.05

c. 0.04 is Correct

d. 0.0

Step-by-step explanation:

Seeing that the Purchase is = 1250,

in other words, purchase > 1000 is valid and therefore the first if block is executed.

And cust = ' N ' and,

if implemented and discountRate fixed to 0.04, cust = = ' Y ' is false, and else within first.

User Yanhui Zhou
by
4.1k points