Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
G'day Basil Uche your temp/100 is giving 0. Remove the parentheses and it kind of works... You also need to make per a float instead of an int, easiest way is to divide by 100.0. Try that? {Edit: sorry yannis2707 I started answering before taking the kids to school, your answer is best!}
20th Feb 2022, 10:12 PM
HungryTradie
HungryTradie - avatar
+ 3
You need to use a double or float in your percentage calculations, otherwise the number will get rounded to 0. int per = total * (temp/100.0); (just add .0 to the 100)
20th Feb 2022, 9:52 PM
yannis2707
yannis2707 - avatar