Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why does Microsoft Visual Studio keep saying there is a compiling error on this code? I can't figure it out and it's due by 11:45pm

Why does Microsoft Visual Studio keep saying there is a compiling error on this code? I can't figure it out and it's due by 11:45pm tonight. PLEASE HELP!!!!

#include #include #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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions