C++ Book an appointment 2. Change an appointment 3. Cancel an appointment 4. View appointment by last name 5. View all appointment

using namespace std;

#include <iostream>
#include <conio.h>
#include <fstream>
#include <iomanip>
#include <string>
#include <stdlib.h>


const unsigned short numComponents = 10;

unsigned short prices[numComponents];
string treatments[numComponents];

void welcome ();
void showMenu ();
void priceList ();
void makeAppointment ();
void openAppointments();
void checkTime();

char choice;
int day;
string date, customer, treatment;
string appBook[5][8][3];

int main () {
       welcome ();
       openAppointments();

   do {
        showMenu ();
        switch (toupper(choice)) {
            case 'A': makeAppointment(); break;
            case 'P': priceList (); break;
            case 'Q': cout << "\\ntThank you for using this application.\n"; break;
            default: cout << "\t\a\a\aInvalid choice.\n\n";
        }
   }
   while (toupper(choice) != 'Q');
   return 0;

}

void welcome () {
// Welcome the user to the program.

     cout << "\n\t\t\t   **************************\n\t\t\t   Curl Up and Dye Hair Salon\n\t\t\t   **************************\n\n";
}

void showMenu () {
// Output the menu to the user.

    cout << "\n\n\t\tSelect one of the following options:\n"
         << "\t\t------------------------------------\n\n"
         << "\t\tA:Make an Appointment\n"
         << "\t\tP: Price List\n"
         << "\t\t\t";
     cin >> choice;
    }

void openAppointments(){

}

void priceList () {
/*
   Reads in the treatments and corresponding prices from the Treatments.txt and PriceList.txt files respectively. The prices are held in the array "prices"
   and the treatments are stored in the array "treatments". You do not need to know how to do this, this is simply for convenience.
*/

    ifstream treatmentFile("treatments.txt"), priceFile("priceList.txt");

    for (unsigned short i = 0; i<numComponents-1; i++) {
       getline (treatmentFile,treatments[i],'\n');
       priceFile >> prices[i];
       }
    treatmentFile.close ();
    priceFile.close ();
    }

void printPrices (string treatments, unsigned short prices[]) {

    for (unsigned short i = 0; i < numComponents; i++) {
      cout << setw (50) << setiosflags(ios::left) << treatments[i] << prices[i] << "\n";
    if (i% 20 == 0 && i != 0)
         getch ();
      }

    }

void showDays () {
// Output the menu to the user.

    cout << "\n\n\t\tSelect one of the following days:\n"
         << "\t\t------------------------------------\n\n"
         << "\t\t0:Monday\n"
         << "\t\t1:Tuesday\n"
         << "\t\t2:Wednesday\n"
         << "\t\t3:Thursday\n"
         << "\t\t4:Friday\n"
         << "\t\t\t";
     cin >> day;
    }

void makeAppointment () {
// Asks the user for the day of the appointment
    showDays();
    switch(day){
    case 0:
        date = "Monday";
        checkTime();
        break;
    case 1:
        date = "Tuesday";
        checkTime();
        break;
    case 2:
        date = "Wednesday";
        checkTime();
        break;
    case 3:
        date = "Thursday";
        checkTime();
        break;
    case 4:
        date = "Friday";
        checkTime();
        break;
    default:
        showMenu();
        break;
    }
}

void checkTime(){
// Checks the arrays for free time and stores the inputs.
    int time;
    bool checkSum = false;

    do{
        cout << "\n\n\t\tEnter time for appointment:\n"
         << "\t\t------------------------------------\n\n";
        cin >> time;
        if(appBook[day][time-9][0] == ""){
           cout << "\n\n\t\tEnter the customer name:\n"
                 << "\t\t------------------------------------\n\n";
            cin >> customer;
            cout << "\n\n\t\tEnter the treatment for "<< customer <<":\n"
                 << "\t\t------------------------------------\n\n";
            cin >> treatment;
            appBook[day][time-9][0] = date;
            appBook[day][time-9][1] = customer;
            appBook[day][time-9][2] = treatment;
            checkSum = true;
        } else {
            cout << "\t\t-----------------------\n\n"
                 << "\n\n\t\tThat time is taken!\n"
                 << "\t\t-----------------------\n\n";
        }
    }while(checkSum == false);

    cout << appBook[day][time-9][1] << " is getting a " << appBook[day][time-9][2] << " at " << time << " on " << appBook[day][time-9][0];
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source