Paint Cost Tax [solved] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Paint Cost Tax [solved]

Can someone explain why I had to use tax = 0.1 in this exercise instead of using tax = 10 and then dividing the total cost * tax by a hundred? Because the second wouldn't solve for case 3 and 4... here's my code, FYI static void Main(string[] args) { int nOC = Convert.ToInt32(Console.ReadLine()); const double tax =0.1; const int pC = 5; const int pB = 40; double totC = pB + pC * nOC; double taxP = totC *tax ; double output = Math.Round (taxP+totC); Console.WriteLine(Convert.ToInt32(output)); }

9th Jul 2022, 2:52 PM
Hannelore Van de Calseyde
Hannelore Van de Calseyde - avatar
2 Answers
+ 3
Each way is good if you use a double for tax.
9th Jul 2022, 2:56 PM
JaScript
JaScript - avatar
+ 1
Ha, before, when tax was still 10, it was an int, so that was the problem. Thank you.
9th Jul 2022, 2:57 PM
Hannelore Van de Calseyde
Hannelore Van de Calseyde - avatar