+ 1

Code coach kaleidoscopes.

Class, could you please explain me where the error in this code challenge. I can't event pass the 1st test case. Sololearn result is totally different from mine, event from the problem stated. Please help me. https://code.sololearn.com/cNRF1dck4Xxl/?ref=app

12th Nov 2022, 1:32 PM
Oliver Pasaribu
Oliver Pasaribu - avatar
8 Antworten
+ 5
Unfortunately we have to pay the taxes to the government and not the other way around. The tax increases the total cost. So change the subtraction to addition, and it will work fine.
12th Nov 2022, 1:38 PM
Tibor Santa
Tibor Santa - avatar
+ 5
Only output what the example shows. Do not output any additional strings.
12th Nov 2022, 1:43 PM
Lisa
Lisa - avatar
+ 3
totalCost = totalCost + totalCost * taxRate;
12th Nov 2022, 3:59 PM
Tibor Santa
Tibor Santa - avatar
+ 2
Tax should be added to total. As already said But Your are subtracting. Discount apply only if quantity>1 Asked to display result round upto 2 decimal digits
12th Nov 2022, 4:06 PM
Jayakrishna 🇮🇳
0
Sure. Please look at line # 41: totalCost = totalCost - totalCost * taxRate; I define tax rate as final double taxRate = 0.07. the result is totally different from the sololearn calculation.
12th Nov 2022, 3:31 PM
Oliver Pasaribu
Oliver Pasaribu - avatar
0
Oh I see, discount Will be given if the urchase quantity > 1. Thank you so much.
12th Nov 2022, 3:36 PM
Oliver Pasaribu
Oliver Pasaribu - avatar
0
Moreover, this is purchasin tax, not revenue tax.
12th Nov 2022, 3:43 PM
Oliver Pasaribu
Oliver Pasaribu - avatar
0
Yes, I understand.
12th Nov 2022, 4:06 PM
Oliver Pasaribu
Oliver Pasaribu - avatar