Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone write Pseudocode for this? #include #include #include // Might need to install this library for 'getch' to work #include #define Max 3 using

Can someone write Pseudocode for this?

#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

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions