What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 100; if (purchase > 1000) discountRate = 0.05; else if (purchase > 750) discountRate = 0.03; else if (purchase > 500) discountRate = 0.01;

Respuesta :

The value of discountRate after the following statements are executed

double discountRate = 0.0;

int purchase = 100;

if (purchase > 1000) discountRate = 0.05;

else if (purchase > 750) discountRate = 0.03;

else if (purchase > 500) discountRate = 0.01;

is 0.0

Explanation:

The discount rate is declared as a double; double discountRate = 0.0;

The purchase is declared as integer; int purchase = 100;

The first if statement shows if purchase > 1000 then the discountRate is 0.05

The second if statement shows if purchase > 750then the discountRate is  0.03

The third if statement shows if purchase > 500 then the discountRate is  0.01

  • Since none of these statements are true, the original discountRate is printed.