Thread: Appointment Book Problem

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    3

    Post Appointment Book Problem

    hi

    i am learning c++ from home and have started a home project in which i am trying to write a program which will allow me to enter a days bookings in an appointment book. For the sake of simplicity i have decided that bookings will only run from 0900 to 1700 and that the output should hopefully be something like the format below:

    15/03/02
    9
    10 booked
    11
    12
    13 booked
    14
    15
    16
    17

    i understand that i need to use an array to hold the time of day but how would I go about programming the code so that

    1. the program will prompt for and accept the days date
    2. initialise all the hours in the day to "free"
    3. repeatedly prompt the user for an hour number
    4. if an hour is free mark it as "booked" otherwise tell the user that it is "already booked"
    5. display the day and its appointments.

    thanks

  2. #2
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    you are asking for a lot....

    *HINT: you should start it yourself and when you encounter a problem then you go about posting this very "single" problem or "function" on the board and people would be able to help you in greater detail....

    matheo917

    ps. don't approach programmig as a whole problem at a time, think of it as bunch of small tasks one-by-one...
    try to right down all your specifications on paper, as well as trying to design a solution in plain "human" words, on paper too......and work from there

  3. #3
    Unregistered
    Guest
    struct Date
    {
    int month;
    int dDate;
    int year;
    };

    struct appointment
    {
    int time;
    bool booked;
    };

    struct Day
    {
    Date date;
    appointment appointments[10];
    };

    struct Calendar
    {
    Day days[30];
    }

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    3

    Unhappy Appointment Book Problem

    When run, my program below allows me to book d first available hours starting from 0900. how can i revise the code so that i can pick which hour i want to book? eg i can pick and book 1400 if it is free, at the moment i can't as it asks me for duration of hours to be booked and it will read from 0900.

    thanks

    #include <iostream.h>
    #include <string.h>
    #include<conio.h>

    struct book
    {
    char time[5];
    bool status;
    };

    void makebook(book z[])
    {
    strcpy(z[0].time,"0900");
    strcpy(z[1].time,"1000");
    strcpy(z[2].time,"1100");
    strcpy(z[3].time,"1200");
    strcpy(z[4].time,"1300");
    strcpy(z[5].time,"1400");
    strcpy(z[6].time,"1500");
    strcpy(z[7].time,"1600");
    strcpy(z[8].time,"1700");

    z[0].status=true;
    z[1].status=true;
    z[2].status=true;
    z[3].status=true;
    z[4].status=true;
    z[5].status=true;
    z[6].status=true;
    z[7].status=true;
    z[8].status=true;
    }

    void printbook(book z[])
    {
    for(int i=0;i<9;i++)
    {
    cout<<i+1<<" "<<z[i].time<<"\t";

    if(z[i].status!=true)
    cout<<"Booked"<<endl;
    else
    cout<<""<<endl;
    }
    }


    void main ()
    {
    book ob[9];
    makebook(ob);

    printbook(ob);

    char date[11];

    cout<<"enter the date in mm/dd/yyyy format : ";
    cin>>date;

    bool ask=true;

    while(ask==true)
    {
    cout<<"Enter number of hour to enter appointment : ";
    int num;
    cin>>num;

    if(ob[num].status==false)
    cout<<ob[num].time<<" is already booked"<<endl;
    else
    {
    cout<<ob[num].time<<" booked now"<<endl;
    ob[num].status=false;
    }

    cout<<"Enter another appointment ? (y/n) : ";
    char temp;
    cin>>temp;
    if(temp=='n')
    ask=false;
    }

    cout<<"Printing Appointments for "<<date<<endl;
    printbook(ob);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Input/output question
    By vice in forum C Programming
    Replies: 8
    Last Post: 04-27-2005, 08:17 AM
  2. Memory leak - need help finding
    By ChadJohnson in forum C++ Programming
    Replies: 8
    Last Post: 04-06-2005, 07:26 PM
  3. memmove problem
    By ChadJohnson in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2005, 06:12 PM
  4. Can't display book and borrower's details.
    By grscot in forum C++ Programming
    Replies: 0
    Last Post: 05-02-2003, 10:18 AM
  5. Books on C and C++
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-28-2002, 04:18 PM