I am trying to compile this program but I keep getting an error message telling me that I'm converting doubles to integers, which I am trying to do, but I can't get it to compile. It's in the "else if " statement near the bottom. It is trying to divide the double "change" into the integers "twenties, tens, etc."
This is not important really but the program is supposed to implement a cash register and if the amount tendered is more the amount of the purchase it will show you how much change you owe, according to the number of twenties, tens, fives, etc.
Code:#include <iostream> using namespace std; int main() { cout << "Enter an amount equal to the amount of a purchase: $"; double amount; cin >> amount; cout << endl << "Enter the amount tendered: $"; double tender; cin >> tender; cout << endl; double change = tender - amount; if (tender < amount) { cout << "The amount tendered was $" << tender << endl; cout << "The amount of the purchase was $" << amount << endl; cout << "Please tender the additional amount of $" << amount-tender << endl; } if (tender > amount && change == 0) { cout << "The amount tendered was $" << tender << endl; cout << "The amount of the purchase was $" << amount << endl; cout << "The total amount of change to be returned to the customer is $" << change << endl; } else if (tender >amount && change > 0) { cout << "The amount tendered was $" << tender << endl; cout << "The amount of the purchase was $" << amount << endl; cout << "The amount of change to be returned to the customer is $" << change << endl; int twenties = change/20; int tens = (change -twenties*20)/10; int fives = (change - tens*10)/5; int ones = (change - fives*5)/1; int quarters = (change - ones*1)/.25; int dimes = (change - quarters*.25)/.10; int nickels = (change - dimes*.10)/.05; int pennies = (changes - nickels*.05)/.01; cout << "This will be returned as:" << endl; cout << "Twenties: " << twenties << endl; cout << "Tens: " << tens << endl; cout << "Fives: " << fives << endl; cout << "Ones: " << ones << endl; cout << "Quarters: " << quarters << endl; cout << "Dimes: " << dimes << endl; cout << "Nickels: " << nickels << endl; cout << "Pennies: " << pennies << endl; } system("pause"); return 0; }