Free source code download for Doctor Appointment Project in C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
#include <iostream> #include <string> #include <fstream> #include <cstring> using namespace std; int Booking() { system("cls"); cout<<"\n ||- Book Your Appointment || \n"; cout<<"\n ||- Availbale slots || \n"; //check if record already exist.. ifstream read; read.open("appointment.dat"); int hoursbook = 8; int arr[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; int Found =0; if(read) { string line; char key = 'A'; int i = 9; while(getline(read, line)) { char temporary = line[0]; int index = (temporary - 65); arr[index]=1; Found = 1; } if(Found == 1) { cout<<"\n Appointment Summary by hours:"; char key = 'A'; int hours = 9; for(int i = 0; i<=12; i++) { if(i == 0){ if(arr[i] == 0) cout<<"\n "<<key<<"-> 0"<<hours<<" - Available"; else cout<<"\n "<<key<<"-> 0"<<hours<<" - Booked"; } else { if(arr[i] == 0) cout<<"\n "<<key<<"->"<<hours<<" - Available"; else cout<<"\n "<<key<<"->"<<hours<<" - Booked"; } hours++; key++; } } read.close(); } if(Found == 0){ cout<<"\n Appointment Available for following hours :"; char key = 'A'; for(int i = 9; i<=21; i++) { if(i==9) cout<<"\n "<<key<<" -> 0"<<i<<" - Available"; else cout<<"\n "<<key<<" -> "<<i<<" - Available"; key++; } } char choice; cout<<"\n\n Input your choice : "; cin>>choice; if( !(choice >= 'A' && choice <='Z')) { cout<"\n Error : Invalid Selection"; cout<<"\n Please selction correct value from menu A- Z"; cout<"\n Press any key to continue"; getchar();getchar(); system("cls"); Booking(); } int index = (choice-65 ); int isBooked = 1; if(arr[index] == 0) isBooked = 0; if(isBooked ==1) { cout<<"\n Error : Appointment is already booked for this Hour"; cout<<"\n Please select different time !!"; cout<<"\n Press any key to continue!!"; getchar();getchar(); system("cls"); Booking(); } string name; cout<<"\n Please Enter your first name:"; cin>>name; ofstream out; out.open("appointment.dat", ios::app); if(out){ out<<choice<<":"<<name.c_str()<<"\n"; out.close(); cout<<"\n Appointment booked for Hours : "<< (choice-65) + 9 <<" successfully !!"; } else { cout<<"\n Error while saving booking"; } cout<<"\n Please any key to continue.."; getchar(); getchar(); return 0; } int existingAppointment() { system("cls"); cout<<"\n ||- Appointments Summary || \n"; //check if record already exist.. ifstream read; read.open("appointment.dat"); int hoursbook = 8; int arr[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; int Found =0; if(read) { string line; char key = 'A'; int i = 9; while(getline(read, line)) { char temporary = line[0]; int index = (temporary - 65); arr[index]=1; Found = 1; } if(Found == 1) { cout<<"\n Appointment Summary by hours:"; char key = 'A'; int hours = 9; for(int i = 0; i<=12; i++) { if(arr[i] == 0) cout<<"\n "<<key<<"->"<<hours<<" - Available"; else cout<<"\n "<<key<<"->"<<hours<<" - Booked"; hours++; key++; } } read.close(); } else { char key = 'A'; for(int i = 9; i<=21; i++) { if(i==9) cout<<"\n "<<key<<" -> 0"<<i<<" - Available"; else cout<<"\n "<<key<<" -> "<<i<<" - Available"; key++; } } cout<<"\n Please any key to continue.."; getchar(); getchar(); return 0; } int main(int argc, char** argv) { while(1) { system("cls"); cout<<"\t\t\tDoctor Appointment System\n"; cout<<"||||||||||||||||||||\n\n"; cout<<"Welcome to projectsinventory.com\n"; cout<<"Press1 For. Book Appointment\n"; cout<<"Press2 For. Check Existing Appointment\n"; cout<<"For 0 For. Exit\n"; int choice; cout<<"\n Please Enter you choice: "; cin>>choice; switch(choice) { case 1: Booking(); break; case 2: existingAppointment(); break; case 0: while(1) { system("cls"); cout<<"\n Are you sure, you want to exit? y | n \n"; char ex; cin>>ex; if(ex == 'y' || ex == 'Y') exit(0); else if(ex == 'n' || ex == 'N') { break; } else{ cout<<"\n Invalid choice !!!"; getchar(); } } break; default: cout<<"\n Invalid choice. Please Enter again "; getchar(); } } return 0; } |
Doctor Appointment System
||||||||||||||||||||
Welcome to projectsinventory.com
Press1 For. Book Appointment
Press2 For. Check Existing Appointment
For 0 For. Exit
Please Enter you choice: 1
||- Book Your Appointment ||
||- Availbale slots ||
Appointment Available for following hours :
A -> 09 – Available
B -> 10 – Available
C -> 11 – Available
D -> 12 – Available
E -> 13 – Available
F -> 14 – Available
G -> 15 – Available
H -> 16 – Available
I -> 17 – Available
J -> 18 – Available
K -> 19 – Available
L -> 20 – Available
M -> 21 – Available
Input your choice :