Scenario-based programs
Scenario 1: 1)Shopping Discount System Input: amount isMember(boolean) Rules: 1. amount ≥ 5000 => 20% discount 2. amount ≥ 2000 => 10% discount 3. Otherwise, no discount 4. members get extra ...

Source: DEV Community
Scenario 1: 1)Shopping Discount System Input: amount isMember(boolean) Rules: 1. amount ≥ 5000 => 20% discount 2. amount ≥ 2000 => 10% discount 3. Otherwise, no discount 4. members get extra 10% discount 5. Print final price after discount. Flow diagram: Program code <!DOCTYPE html> <html> <title>Shopping task scenario</title> <head> <body> <script> let amount = 5000; let ismember = true; let discount = 0; if(amount >= 5000) { discount = 20; } else if(amount >= 2000) { discount = 10; } else { discount = 0; } if(ismember) { discount = discount + 10; } let finalprice = amount - (amount * discount/100) document.write("Final price concluded" + finalprice) </script> </body> </head> </html> Output Final price concluded3500 Scenario 2 2)Login Access Check Input username password isBlocked(boolean) Rules Allow login only if: username is "Test" password is "pwd" user is not blocked Otherwise print an appropriate messa