Loading...
Loading...
Loading...
A shopping app charges a fee by payment mode: UPI and DEBIT_CARD are free, CREDIT_CARD costs 2% of the amount (rounded down), and NET_BANKING costs a flat Rs. 10.
Declare enum PaymentMode and write fee as a switch expression with no default. Print each payment and the total fees.
MODE: fee F, pay P (P = amount + fee), then Fees: Rs. total.Example
Input
3 UPI 500 CREDIT_CARD 1250 NET_BANKING 999
Output
UPI: fee 0, pay 500 CREDIT_CARD: fee 25, pay 1275 NET_BANKING: fee 10, pay 1009 Fees: Rs. 35
2% of 1250 is 25.
Try the problem first. Open one hint at a time.
case UPI, DEBIT_CARD -> 0; shares one branch.
amount * 2 / 100 rounds down because both are int.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor