Question
Why does the compiler keep saying there is an error on this code? I cant figure it out and its due by 11:45 pm tonight.
Why does the compiler keep saying there is an error on this code? I cant figure it out and its due by 11:45 pm tonight. I just paid $40 to get this question answered please help me!!!!!!!!!!
#include
using namespace std;
int main() { //Variables double cost, payment, change; int twenty, ten, five, one, quarter, dime, nickel, penny; //Have user enter the total cost of purchase cout << "Enter the cost of purchase:" << endl; cin >> cost; while (cost <= 0) { cout << "Enter a cost value higher 0:" << endl; cin >> cost; } cout << "Enter how much the customer paid:" << endl; cin >> payment; while (cost > payment) { cout << "Enter a payment value higher than the cost value:" << endl; cin >> payment; } cout << endl << endl << endl << "Total Change: $"; change = payment - cost; cout << fixed << setprecision(2) << change << endl; int total = (int)100 * change; //Processing (converting total change into the specific number of billsand coins that are need to give back to customer) twenty = total / 2000; total = total % 2000; ten = total / 1000; total = total % 1000; five = total / 500; total = total % 500; one = total / 100; total = total % 100; quarter = total / 25; total = total % 25; dime = total / 10; total = total % 10; nickel = total / 5; total = total % 5; penny = total; cout << endl << "Change in bills and coins: " << endl; //Final Output if (twenty != 0) { cout << "Twenties: "; cout << setw(3) << twenty << endl; } if (ten != 0) { cout << "Tens: "; cout << setw(7) << ten << endl; } if (five != 0) { cout << "Fives: "; cout << setw(6) << five << endl; } if (one != 0) { cout << "Ones: "; cout << setw(7) << one << endl; } if (quarter != 0) { cout << "Quarters: "; cout << setw(3) << quarter << endl; } if (dime != 0) { cout << "Dimes: "; cout << setw(6) << dime << endl; } if (nickel != 0) { cout << "Nickels: "; cout << setw(4) << nickel << endl; } if (penny != 0) { cout << "Pennies: "; cout << setw(4) << penny << endl; }
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started