Loading...
Loading...
Loading...
The canteen till has three overloaded static methods named total: total(price), total(price, qty) and total(price, qty, discount), where the discount is a flat amount taken off the whole bill. Read each order and call the overload that matches the number of values.
Example
Input
3 1 20 2 15 4 3 40 5 25
Output
20 60 175
40 × 5 − 25 = 175.
Try the problem first. Open one hint at a time.
Same name, different number of parameters: the compiler picks the version from the arguments.
Read k first, then read exactly k numbers and call total with that many arguments.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor