Loading...
Loading...
A clothing store gives a discount based on the bill amount:
Members get an extra 5% on top of this, on any bill. Read the bill amount and whether the customer is a member (Y or N). Print the total discount percent and the amount to pay with exactly two decimal places.
Y or N.Discount: P% and Pay: X.XX.Y or N (capital).Example 1
Input
2500 N
Output
Discount: 10% Pay: 2250.00
10% off 2500 is 250, so pay 2250.00.
Example 2
Input
999 Y
Output
Discount: 5% Pay: 949.05
No bill discount, but members get 5%: 999 × 0.95 = 949.05.
Try the problem first. Open one hint at a time.
First find the bill discount with an else-if ladder from the highest band down.
Then add 5 if the customer is a member.
Pay = amount × (100 − percent) / 100. Divide by 100.0 so the paise are kept, and print with printf("Pay: %.2f%n", ...).
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor