Free2Code
The majority of forums are now only available as archives, which means posting/editing is disabled.

The Anything and Everything forum is still open.
 
Time: 2013-05-18, 08:57am
HELP
Subject: HELP  ·  Posted: 2004-03-31, 10:29am
Rank: Unregistered
Hi wondering if u could help I have a program,
I need to add some code to the user can request the first free hour, heres my code so far, can any1 help me.

#include <iostream.h>

class bookinsys{
int day[9];


public:
bookinsys();
void appt(int num);
void display();
void GetDate(int &dd, int &mm, int &yy);
void FormatDate(int dd, int mm, int yy);

};

bookinsys::bookinsys()
{
int i;
for (i= 0; i<9; i++)
day[i] = 0;
}


void bookinsys::appt(int num)
{
int k;
k = num - 9;
if (day[k] == 0) {
cout<< "This is your allocated time "<<k + 9<<"\n";
day[k] = 1;}
else cout<< " Place Filled\n";
}
void bookinsys::display()
{
int i;
for (i= 0; i<9; i++)
if (day[i] == 0)
cout<< (i+9) << " Avalible\n";
else cout<< (i+9) <<" Booked\n";
}

main() {
void GetDate(int &dd, int &mm, int &yy);
void FormatDate(int dd, int mm, int yy);
bookinsys t;
int n;
cout << "Please enter Today's Date (dd mm yy) : ";
int day, month, year;
GetDate(day, month, year);
cout<<"The Date you entered was : ";
FormatDate(day, month, year);
cout<<"\n";
while ( n != 18){
cout<< " Choose an hour between 9 and 17\n";
cin>> n;
t.appt(n);
t.display();}
int s; cout<<"enter s to stop"; cin>>s;
return 0;
}


void GetDate(int &dd, int &mm, int &yy){
cin >> dd;
cin >> mm;
cin >> yy;
}
void FormatDate(int dd, int mm, int
yy){
cout << dd << ":" << mm << ":" << yy;
}

 
  Reply to this ·  Post link ·  Top
Subject: Re: HELP  ·  Posted: 2004-03-31, 10:33am
Rank: ? (39)
Member #: 14820
Code:
  1. #include <iostream.h>
  2. class bookinsys{
  3. int day[9];
  4. public:
  5. bookinsys();
  6. void appt(int num);
  7. void display();
  8. void GetDate(int &dd, int &mm, int &yy);
  9. void FormatDate(int dd, int mm, int yy);
  10. };
  11. bookinsys::bookinsys()
  12. {
  13. int i;
  14. for (i= 0; i<9; i++)
  15. day[i] = 0;
  16. }
  17. void bookinsys::appt(int num)
  18. {
  19. int k;
  20. k = num - 9;
  21. if (day[k] == 0) {
  22. cout<< "This is your allocated time "<<k + 9<<"\n";
  23. day[k] = 1;}
  24. else cout<< " Place Filled\n";
  25. }
  26. void bookinsys::display()
  27. {
  28. int i;
  29. for (i= 0; i<9; i++)
  30. if (day[i] == 0)
  31. cout<< (i+9) << " Avalible\n";
  32. else cout<< (i+9) <<" Booked\n";
  33. }
  34. main() {
  35. void GetDate(int &dd, int &mm, int &yy);
  36. void FormatDate(int dd, int mm, int yy);
  37. bookinsys t;
  38. int n;
  39. cout << "Please enter Today's Date (dd mm yy) : ";
  40. int day, month, year;
  41. GetDate(day, month, year);
  42. cout<<"The Date you entered was : ";
  43. FormatDate(day, month, year);
  44. cout<<"\n";
  45. while ( n != 18){
  46. cout<< " Choose an hour between 9 and 17\n";
  47. cin>> n;
  48. t.appt(n);
  49. t.display();}
  50. int s; cout<<"enter s to stop"; cin>>s;
  51. return 0;
  52. }
  53. void GetDate(int &dd, int &mm, int &yy){
  54. cin >> dd;
  55. cin >> mm;
  56. cin >> yy;
  57. }
  58. void FormatDate(int dd, int mm, int
  59. yy){
  60. cout << dd << ":" << mm << ":" << yy;
  61. }


Notice: If you notice this notice, you should also notice that this notice is not a notice!
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs