Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help me fix this code so it outputs properly In order to better organize its business, the Lawrenceville Lawn Service wants to computerize

can someone help me fix this code so it outputs properly

In order to better organize its business, the Lawrenceville Lawn Service wants to computerize its customer list. The information for each customer(name, address, size of lawn, and day of the week they wish their lawn to be mowed) should be stored in parallel arrays. Write a program that allows the user to perform the following functions:

Add a new customer

Remove a customer

Display a table of jobs for a given day. The table should be similar to the one shown in the sample run below, showing the name, address, cost and total charge including 7% sales tax. LLS charges 2 cents per square yard for cutting.

When run, the program output should look similar to:

Enter Display, Add, dElete, Quit: a ADD Enter name to be added: Tiger Woods Enter address: 65 Lakeshore Drive Enter lawn size: 1262 Enter day to be cut: Saturday Enter Display, Add, dElete, Quit: a ADD Enter name to be added: Julia Winitsky Enter address: 16 Manor Dr Enter lawn size: 2500 Enter day to be cut: Tuesday Enter Display, Add, dElete, Quit: e Delete Enter name for deletion: Tiger Woods ** DELETED ** Enter Display, Add, dElete, Quit: e DELETE Enter name for deletion: Josephine Bouchard ** Error Name not on list ** Enter Display, Add, dElete, Quit: X ** Please enter D, A, E, or Q ** Enter Display, Add, dElete, Quit: d DISPLAY Enter day for list: Tuesday LAWRENCEVILLE LAWN SERVICE Schedule for: Tuesday NAME ADDRESS COST TOTAL Julia Winitsky 16 Manor Dr. $50.00 $53.50 Enter Display, Add, dElete, Quit: q QUIT ** Program complete **

code:

#include #include #include

using namespace std;

const double COST_PER_SQ_YARD = .02; const double TAX_RATE = .07;

string name[20]; string address[20]; int size[20]; string day[20];

int customerCount = 0;

void displayMenu(); void addCustomer(); void deleteCustomer(); void displayListByDay();

int main() { char userInput;

cout << "Welcome to Lawrenceville Lawn Service!" << endl; displayMenu(); cin >> userInput; userInput = toupper(userInput);

while (userInput != 'Q'){ switch (userInput) { case 'D': displayListByDay(); break; case 'A': addCustomer(); break; case 'E': deleteCustomer(); break; default: cout << "Please enter D, A, E, or Q" << endl; break; } displayMenu(); cin >> userInput; userInput = toupper(userInput); }

cout << "Program complete" << endl;

return 0; }

void displayMenu() { cout << "Enter Display, Add, dElete, Quit: "; }

void addCustomer() { string nameInput; string addressInput; int sizeInput; string dayInput;

cout << "ADD" << endl; cout << "Enter name to be added: "; cin >> nameInput; cout << "Enter address: "; cin >> addressInput; cout << "Enter lawn size: "; cin >> sizeInput; cout << "Enter day to be cut: "; cin >> dayInput;

name[customerCount] = nameInput; address[customerCount] = addressInput; size[customerCount] = sizeInput; day[customerCount] = dayInput; customerCount++; }

void deleteCustomer() { string nameInput; bool deleted = false;

cout << "DELETE" << endl; cout << "Enter name for deletion: "; cin >> nameInput;

for (int i = 0; i < customerCount; i++) { if (name[i] == nameInput) { for (int j = i; j < customerCount - 1; j++) { name[j] = name[j + 1]; address[j] = address[j + 1]; size[j] = size[j + 1]; day[j] = day[j + 1]; } customerCount--; deleted = true; break; } }

if (deleted) cout << "** DELETED **" << endl; else cout << "** Error Name not on list **" << endl; }

void displayListByDay() { string dayInput;

cout << "DISPLAY" << endl; cout << "Enter day for list: "; cin >> dayInput;

cout << endl; cout << "LAWRENCEVILLE LAWN SERVICE" << endl; cout << "Schedule for: " << dayInput << endl; cout << endl; cout << left << setw(20) << "NAME"; cout << left << setw(20) << "ADDRESS"; cout << left << setw(20) << "COST"; cout << left << setw(20) << "TOTAL" << endl;

for (int i = 0; i < customerCount; i++) { if (day[i] == dayInput) { cout << left << setw(20) << name[i]; cout << left << setw(20) << address[i]; cout << left << setw(20) << fixed << setprecision(2) << "$" << size[i] * COST_PER_SQ_YARD; cout << left << setw(20) << fixed << setprecision(2) << "$" << (size[i] * COST_PER_SQ_YARD) * (1 + TAX_RATE) << endl; } } }

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions