I am writing a c++ program to turn a number into coins. I got the program written and it works perfect if the input is in decimal form. i.e .87 for 87 cents. However, I need to know how to get the user input (87) to convert into a decimal. If the user inputs 87 it changes to 348 quarters. if the user inputs .87 it changes to 3 quarters, 1 dime, o nickles, and 2 pennies.
I'd prefer the user to just enter a whole number... Thanks
#include <iostream>
using namespace std;
int main()
{
double userNumber;
int change, quarters, dimes, nickels, pennies; // declare variables
cout << "Please enter an amount in cents less than a dollar: ";
cin >> userNumber; // input the amount of change
change = userNumber * 100;
quarters = change / 25; // calculate the number of quarters
change = change % 25; // calculate remaining change needed
dimes = change / 10; // calculate the number of dimes
change = change % 10; // calculate remaining change needed
nickels = change / 5; // calculate the number of nickels
pennies = change % 5; // calculate pennies