Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me edit this code so it doesn't use curses.h and remove the $ from showing under quantity where the cost summary is?

Can someone help me edit this code so it doesn't use curses.h and remove the $ from showing under quantity where the cost summary is?

#include #include #include // Might need to install this library for 'getch' to work #include

#define Max 3 using namespace std;

int main() { string names[Max]; float prices[Max]; int quantity[Max]; int tax; float total = 0; float afterTax = 0; int paid; float balance; cout << "---------- Panther Express cashier's program ----------" << endl;

// 1st Item cout << "Unit name : "; cin >> names[0]; cout << "Unit price for " << names[0] << ": "; cin >> prices[0]; cout << "Unit quantity for " << names[0] << ": "; cin >> quantity[0]; cout << " ";

// 2nd Item cout << "Unit name : "; cin >> names[1]; cout << "Unit price for " << names[1] << ": "; cin >> prices[1]; cout << "Unit quantity for " << names[1] << ": "; cin >> quantity[1]; cout << " ";

// 3rd Item cout << "Unit name : "; cin >> names[2]; cout << "Unit price for " << names[2] << ": "; cin >> prices[2]; cout << "Unit quantity for " << names[2] << ": "; cin >> quantity[2]; cout << " ";

cout << "Tax rate (in whole numbers): "; cin >> tax; cout << " $--------- cost summary ---------$ "; cout << "Item" << setw(20) << "price" << setw(20) << "quantity" << setw(20) << "cost" << endl; cout << "-------------------------------------------------------------------------------------- ";

// 1st Item cout << left << setw(19) << names[0]; cout << "$" << left << setw(16) << prices[0]; cout << "$" << left << setw(23) << quantity[0]; cout << "$" << left << setw(19) << (prices[0] * quantity[0]) << endl; total += prices[0] * quantity[0];

// 2nd Item cout << left << setw(19) << names[1]; cout << "$" << left << setw(16) << prices[1]; cout << "$" << left << setw(23) << quantity[1]; cout << "$" << left << setw(19) << (prices[1] * quantity[1]) << endl; total += prices[1] * quantity[1];

// 3rd Item cout << left << setw(19) << names[2]; cout << "$" << left << setw(16) << prices[2]; cout << "$" << left << setw(23) << quantity[2]; cout << "$" << left << setw(19) << (prices[2] * quantity[2]) << endl; total += prices[2] * quantity[2];

cout << " $--------cost pretax--------$" << endl; cout << total << endl; cout << " $--------cost w/ tax--------$" << endl; afterTax = total * (1 + (float)tax / 100); afterTax = (afterTax * 100) / 100; cout << afterTax << endl; cout << " -------------------------------------------------------------------------------------- "; cout << "How much do you have "; cin >> paid; balance = paid - afterTax; balance = balance * 100 / 100; cout << " $----------Change---------$" << endl; cout << balance << endl; cout << "-------------------------------------------------------------------------------------- "; cout << " Denominations ... "; // First process the whole number. Divide by currency denominations and print balance int intBalance = (int)balance; float decimal = balance; decimal -= intBalance; int count = intBalance / 100; intBalance %= 100; cout << setw(25) << "$100 bills: " << count << endl; count = (int)intBalance / 20; intBalance %= 20; cout << setw(25) << "$20 bills: " << count << endl; count = (int)intBalance / 10; intBalance %= 10; cout << setw(25) << "$10 bills: " << count << endl; count = (int)intBalance / 5; intBalance %= 5; cout << setw(25) << "$5 bills: " << count << endl; count = (int)intBalance; cout << setw(25) << "$1 bills: " << count << endl; // Process decimal points. Divide by currency denominations and print balance intBalance = (int)(decimal * 100); count = (int)intBalance / 25; intBalance %= 25; cout << setw(25) << "Quarters: " << count << endl; count = (int)intBalance / 10; intBalance %= 10; cout << setw(25) << "Dimes: " << count << endl; count = (int)intBalance / 5; intBalance %= 5; cout << setw(25) << "Nickels: " << count << endl; cout << setw(25) << "Pennies: " << intBalance << endl;

cout << " Press any key to exit "; int in; in = getch(); 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_2

Step: 3

blur-text-image_3

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

How do books become world of wonder?

Answered: 1 week ago

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago