Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a c++ program using the information Alexamara tables . A program that that

ID: 3711735 • Letter: W

Question

Write a c++ program using the information Alexamara tables. A program that that will list this table, then under that each owner first and last name and city, then under each owner list each boat, and under each boat list all of the service requests (description and status). Use your own good judgment about how to organize your code and your output. Use appropriate documentation.

LastName | FirstName | City | State |Name | Bay Shores FL Alexamara CentralI Trent Ashton Adney Bruce and Doris Bowtorn Adney Bruce and Doris| Bowton Bowton | Bowton | Bowton | FL | FL | FL | FL | FL Alexamara East I Alexamara Central | Alexamara South | Blake Mary Jane |Blake Mary Jane | Kelly Alyssa Alexamara East Alexamara Central | Anderson|Bi ll | Glander Bay | FL Alexamara East | SmeltzBecky and Dave Glander Bay | FL Alexamara Central | | Feenstra | Daniel | FL | FL | Kaleva Kaleva Alexamara East Feenstra | Daniel Alexamara Central | | Smith Peter | Lewiston FL Alexamara Central | Elend Mary and Bill Rivard Rivard | FL Alexamara East | FL Alexamara South | Juarez Maria

Explanation / Answer

#include <mysql.h>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <typeinfo>

using namespace std;

MYSQL *conn, mysql;
MYSQL_RES *res;
MYSQL_ROW row;

//Queries the MySQL database for information pertaining to boats, and prints it to the screen.

void get_boats() {
   int query_state = mysql_query(conn, "SELECT FirstName, LastName, Address, SlipID, MarinaNum from MarinaSlip inner join Owner on MarinaSlip.OwnerNum = Owner.OwnerNum");
   if (query_state != 0) {
       cout << mysql_error(conn) << endl;
       return;
   }
   res = mysql_store_result(conn);

   cout << endl << setw(17) << "Marina" << setw(15) << "Name" << setw(20) << "Address" << setw(9) << "SlipID" << endl;
   cout << endl;
   while ((row=mysql_fetch_row(res)) != NULL) {
       string name;
       if (*row[4] == '1') {
           name = "Alexamara East";
       }
       else {
           name = "Alexamara Central";
       }
       cout << setw(17) << name << setw(15) << row[1] << setw(20) << row[2] << setw(9) << row[3] << endl;
   }
}


//Queries the MySQL database for information pertaining to Maintenance, and prints it to the screen.

void get_maintenance() {
   int query_state = mysql_query(conn, "select BoatName, ServiceRequest.Description from MarinaSlip left join ServiceRequest on MarinaSlip.SlipID = ServiceRequest.SlipID order by BoatName");
   if (query_state != 0) {
       cout << mysql_error(conn) << endl;
   }
   res = mysql_store_result(conn);


   cout << endl << setw(15) << "Boat Name" << setw(80) << "Problem Description" << endl;
   cout << endl;
   while ((row=mysql_fetch_row(res)) != NULL) {
       if (row[1] == NULL) {
           cout << setw(15) << row[0] << setw(110) << "No Problems Have Been Reported For This Boat." << endl;
       }
       else {
           cout << setw(15) << row[0] << setw(110) << row[1] << endl;
       }
   }
}

//Queries the MySQL database for information pertaining to Service Counts, and prints it to the screen.

void get_counts() {
   int query_state = mysql_query(conn, "select CategoryDescription, count(*) from ServiceCategory inner join ServiceRequest on ServiceRequest.CategoryNum = ServiceCategory.CategoryNum group by CategoryDescription");
   if (query_state != 0) {
       cout << mysql_error(conn) << endl;
   }
   res = mysql_store_result(conn);

   cout << endl << setw(50) << "Category" << setw(7) << "Count" << endl;
   cout << endl;
   while ((row=mysql_fetch_row(res)) != NULL) {
       cout << setw(50) << row[0] << setw(7) << row[1] << endl;
   }
}

//Prompts the user to select and option, and performs an action based on that choice
int menu() {
   int choice;
   cout << endl << "Choose a Report" << endl <<
   "1. Boats" << endl <<
   "2. Maintenance" << endl <<
   "3. Service Counts" << endl <<
   "4. Exit" << endl;

   cin >> choice;
   cin.clear();
   switch (choice) {
       case 1: {
           get_boats();
           return 1;
       }
       case 2: {
           get_maintenance();
           return 2;
       }
       case 3: {
           get_counts();
           return 3;
       }
       case 4: {
           return 4;
       }
       default: {
           cout << endl << "Please enter a valid choice" << endl;
           return -1;
       }
   }
}


int main() {
  
   mysql_init(&mysql);

   int query_state;
   char *server = (char *)"courses";
   char *user = (char *)"z1693990";
   char *password = (char *)"1995Jan24";
   char *database = (char *)"z1693990";

   conn = mysql_real_connect(&mysql, server, user, password, database, 0, 0, 0);

   if (conn == NULL) {
       cout << endl << mysql_error(&mysql) << endl;
       return 0;
   }
   int x = 0;

   while ( x != 4) {
       x = menu();
   }
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote