Question: #include // I/O operations #include // Formatting functions #include // General use library functions #include // Defines dynamic string stuff using namespace std; // Creation
#include// I/O operations #include // Formatting functions #include // General use library functions #include // Defines dynamic string stuff using namespace std; // Creation of Data Structure(s) struct bookstore { string isbn; string title; string author; string enroll; //expected number of students string cond; //New (N)/Used (U) string R; //Required/ Recommended };// End of Creation of Data Structures // Function prototypes int splashScreen(void); int pageContinue(void); void scrnHeading(string title); // New - prints Project name and // screen title (via parameter list) bookstore inputScreen(void); int outputScreen(string isbn, string title, string author, string enroll, string cond, string r); int mainMenu(bookstore s[], int max_book); // note the array notation int bookArrayInput(bookstore s[], int max); // wrapper for inputScreen() int isbnSearch(bookstore s[], int numbook); int displbookAry(bookstore s[], int numbook); void sorttitle(bookstore s[], int numbook); // End of Function Prototypes int main() { //-------- Start of variable and object creation ------ bookstore Books[50]; int max_book = 50; int flag = 0; //-------- End of variable declarations --------------------- splashScreen(); // No changes flag = mainMenu(Books, max_book); return 0; } // Start of Function Definitions int splashScreen(void) // No changes { system("cls"); //Call to the OS. MS specific cout << endl << endl << endl << endl; //4 blank lines cout << " Miramar College" << endl; cout << endl << endl; cout << " Bookstore Order System" << endl; cout << endl << endl << endl << endl << endl << endl; // 6 blank lines cout << " Hada Marabeh" << endl; cout << endl << endl << endl << endl << endl << endl << endl << endl; pageContinue(); return 0; } // End of int SplashScreen(void) void scrnHeading(string title) { system("cls"); cout << endl << endl; cout << " Miramar College" << endl; cout << endl; cout << " Bookstore Order System" << endl; cout << endl; cout << setw(((80 - title.length()) / 2.0) + title.length()) << title << endl; cout << endl; } int pageContinue(void) // No changes from the previous chapter { string resp = "XXX"; // Because this variable is only used here cout << " Press to Continue"; getline(cin, resp); system("cls"); return 0; } // End of int PageContinue(void) bookstore inputScreen(void) { bookstore one; scrnHeading("Input Screen"); cout << " Enter data as requested and press after each." << endl; cout << endl; cout << " Isbn: "; getline(cin, one.isbn); cout << " Title: "; getline(cin, one.title); cout << endl; cout << " Author: "; getline(cin, one.author); cout << " Expected Number of Enrollment: "; getline(cin, one.enroll); cout << endl; cout << " New (N) or Used (U)"; getline(cin, one.cond); cout << " Required (r) or Recommended (R): "; getline(cin, one.R); cout << endl << endl << endl << endl; pageContinue(); return one; } // End of int inputScreen( ) int outputScreen(string isbn, string title, string author, string enroll, string cond, string r) // No changes here { //Calculation variable creation //double enroll = 0.0; //number of studnets //double req or rec = 0.0; //required or recommended double tot_cost = 0.0; //total cost // End of calculation variable creation int pay_rate = '0'; int condNew = '0'; int tot_pay = '0'; condNew = atof(cond.data()); scrnHeading("Output Screen"); cout << endl << endl << endl; cout << " Book's Isbn & Title: " << isbn << " " << title << endl; cout << " Author: " << author << endl; cout << " Enrollment: " << enroll << endl; cout << endl; cout << " Condition: " << setw(16) << cond << "Require or Recommended: " << r << endl; cout << endl; // Conversions, Decisions and Calculations enroll = atof(enroll.data()); //.data() converts dynamic string to a char array; atof converts char // array to a double //Determine the pay rate based on job position and status if (cond.at(0) == 'N') if (cond.at(0) == 'U') pay_rate = 0.5; else pay_rate = 0.27; else if (r.at(0) == 'R') if (r.at(0)== 'R') pay_rate = 0.16; else pay_rate = 0.1; tot_cost = pay_rate * condNew; // Calculates total pay cout << setw(35) << "Total Cost: " << fixed << setprecision(2) << tot_pay << endl; cout << endl << endl << endl << endl; //Transition to next screen pageContinue(); //End of transition return 0; } // End of int outputScreen( ) int mainMenu(bookstore s[], int max) { // Creation of local variables bookstore one; string ans = "XXXX", resp = "XXXX"; int ctr = 0; int numbook = 0; int condition = -1; do { scrnHeading("Main Menu Screen"); cout << endl; for (ctr = 0; ctr < 79; ctr++) cout << "-"; cout << endl; cout << endl; cout << " nput a Records" << endl; cout << endl; cout << " utput a Records" << endl; cout << endl; cout << " earch Records by Last Name" << endl; cout << endl; cout << " sort Records by Last Name" << endl; cout << endl; cout << " xit" << endl; for (ctr = 0; ctr < 79; ctr++) cout << "-"; cout << endl; cout << endl << endl << endl; cout << " Enter I, O, S, or E: "; getline(cin, ans); if(ans.empty()) ans = "XXX"; system("cls"); //-------- End of Menu options --------------------------- switch (ans.at(0)) { //Beginning of the switch block case 'S': case 's': condition = isbnSearch(s, numbook); if (condition == numbook) { scrnHeading("Book NOT found"); for (int i = 0; i < 18; i++) cout << endl; pageContinue(); } else outputScreen(s[condition].isbn, s[condition].title, s[condition].author, s[condition].enroll, s[condition].cond, s[condition].R); break; case 'I': case 'i': //-------- Call to Array Input ---------------------------- numbook = bookArrayInput(s, max); break; case 'O': case 'o': displbookAry(s, numbook); break; case 'R': case 'r': sorttitle(s, numbook); break; case 'E': case 'e': // Exit option -- prevents the default option from executing break; default: cout << endl << endl << endl; scrnHeading("ERROR Screen"); cout << endl; for (ctr = 0; ctr < 79; ctr++) cout << '-'; cout << endl << endl; cout << " Bummer -- You were to enter I, O, or E!!" << endl; cout << endl; cout << " Press to Continue" << endl; getline(cin, resp); system("cls"); } // End of switch(resp.at(0)) } while (ans.at(0) != 'E' && ans.at(0) != 'e'); // End of the menu processing return 1; } int bookArrayInput(bookstore s[], int max) { int numRcds = 0; string resp = "XXXX"; int ctr = 0; // for formatting loop scrnHeading(" Array Input Screen "); for (ctr = 0; ctr < 4; ctr++) cout << endl; cout << " Enter a record (Y/N): "; getline(cin, resp); while (toupper(resp.at(0)) == 'Y') // Anything but 'Y' is NO! { s[numRcds] = inputScreen(); // inputScreen() call numRcds++; // identifies the number of records entered. scrnHeading("Array Input Screen"); cout << " Enter another record (Y/N): "; getline(cin, resp); } // End of while( toupper( resp.at(0)=='Y' ) return numRcds; } // End of int empArrayInput( employee s[], int max ) int isbnSearch(bookstore s[], int numbook) { int cond = 0; string srchtitle = "XXXX"; scrnHeading("ISBN Search Screen"); cout << endl << endl << endl; cout << "Enter a ISBN or TITLE to locate: "; getline(cin, srchtitle); while ((cond < numbook) && (srchtitle != s[cond].isbn)) cond++; return cond; } //End of int isbnSearch( bookstore s[], int numbook) int displbookAry(bookstore s[], int numbook) { int ctr = 0; scrnHeading("Data Table"); cout << endl << endl; cout << setw(10) << "ISBN" << setw(11) << "Title" << setw(10) << "Author"; cout << setw(6) << "Enrollment" << setw(9) << "Condition" << setw(9) << "Required or Recommended"; for (ctr = 0; ctr < 79; ctr++) cout << '-'; cout << endl; for (ctr = 0; ctr < numbook; ctr++) { cout << setw(10) << s[ctr].isbn << setw(10) << s[ctr].title << setw(10) << s[ctr].author; cout << setw(6) << s[ctr].enroll << setw(8) << s[ctr].cond << setw(8) << s[ctr].R; } cout << endl << endl; cout << "Number of Books: " << numbook << endl; cout << endl << endl; pageContinue(); return 1; } //End of int displEmplAry( empoyee s[], int numEmpl ) void sorttitle(bookstore s[], int numbook) { int i, j; // counters for the two loops bookstore temp; for (i = 0; i < (numbook - 1); i++) for (j = (i + 1); j < numbook; j++) if (s[i].isbn > s[j].isbn) { temp = s[i]; s[i] = s[j]; s[j] = temp; } } // End of void sorttitle( bookstore s[ ], int numbook)
I have tried googling it and I've asked for help and I am sitll lost and confused. There are a few things I am missing which are listed below.
I need to add:
- Printer Function
- 2 more searches
- different output
PLESE HELP!!!
Thank You!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
