+ 1

Here is the full code, please i need help!!

int main() { float houses; float dollar; cin >> houses; //your code goes here { dollar = (((houses - (houses - 2))) / houses) * 100; if (dollar == (int)dollar) { cout << dollar; } else cout << (int)dollar + 1; } return 0; }

16th Feb 2022, 8:03 PM
DevAbdul
DevAbdul - avatar
3 ответов
+ 2
Note that the dollar calculation can be simplified to (2.0/houses)*100.0, and further to 200.0/houses. The if/else statement is there to find the ceiling of dollar. If dollar is already an integer value, then print it. Else, print the next higher integer. Here is a simpler version that might be easier to understand: #import <math> . . . cin >> houses; cout << (int)ceil(200.0/houses);
16th Feb 2022, 10:12 PM
Brian
Brian - avatar
16th Feb 2022, 9:14 PM
Raul Ramirez
Raul Ramirez - avatar
+ 1
Baiscally its just rounding the dollar to the nearest 1 So if dollar is 16.5 then round to 17
16th Feb 2022, 9:15 PM
Raul Ramirez
Raul Ramirez - avatar