0%
0 / 12 answered
Nested if Statements Practice Test
•12 QuestionsQuestion
1 / 12
Q1
Online Shopping Cart: apply discount using nested if. Code:
boolean isMember = true;
double purchaseAmount = 120.0, discount = 0.0;
// Members get higher discount for large purchases
if (isMember) {
discount = 0.10;
if (purchaseAmount >= 100.0) discount = 0.20;
}
What will be the output if the input is isMember=true, purchaseAmount=120.0?
Online Shopping Cart: apply discount using nested if. Code:
boolean isMember = true;
double purchaseAmount = 120.0, discount = 0.0;
// Members get higher discount for large purchases
if (isMember) {
discount = 0.10;
if (purchaseAmount >= 100.0) discount = 0.20;
}
What will be the output if the input is isMember=true, purchaseAmount=120.0?