So I am taking C++ at thomas edison state college for a degree. I needed a computer course so I chose C++ instead of PLCs. The reason being is that I used to do some basic coding back in the apple IIe days. I apparently don't have the attention span or interest anymore so I am having issues. Maybe its kids or wife or whatnot. I do understnd it is different progrmming. Now the problem I have is that I cannot figure out how to math it correctly. For instance when I enter 1.88 it gives me the appropriate amount of coins using standard US currency. When I enter any value that has 2 pennies and zero nickles it gives the wrong amount..-ie 1 penny. How do I fix this...I've been wracking my brain and well it's not in there. Please help!
PS- Not sure if this was posted somewhere else I'm new to this forum and to C++.
PSS- I can post the actual problem if that would help. I'm looking for guidance since I want to understand.
#include <iostream>
using namespace std;
int main ( )
{
float change;
int variable, quarters, dimes, nickels, pennies;
cout <<"Please enter a value: ";
cin >> change;
variable = change * 100;
quarters = variable / 25;
variable = variable % 25;
dimes = variable / 10;
variable = variable % 10;
nickels = variable / 5;
pennies = variable % 5;
cout << "\nQuarters: " << quarters << "\n";
cout << " Dimes: " << dimes << "\n";
cout << " Nickels: " << nickels << "\n";
cout <<" Pennies: " << pennies << "\n";
return (0);
}