0

I want to confirm that my code is running well, as there is only one example to check if the program is right. 0.41 outputs 4. And that is what I am getting, If code is Ok, I am having problem with line twenty,(where I commented) after converting change from Naira to cents. I want to convert change from float to Int. I tried to use int change*= 100. but I am getting a scope variable error. And I tried every other way to convert change from float to int. Thanks.

enter image description hereenter image description hereenter image description hereenter image description hereenter image description here

1

You are declaring

int change *= 100;

when there is already a variable 'change' in the current scope. You can't have more than one variable with the same name which is why you get that error.

You can cast a float to an int like this

int x = int(change);
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .