rendered paste body#include <iostream>
#include <fstream>
#include <string>
using namespace std;
float getFloat(string prompt) {
char input[8];
float f;
cout << endl << prompt;
cin >> input;
f = (float)atof(input);
return f;
}
string getString(string prompt) {
string s;
cout << endl << prompt;
getline(cin, s);
return s;
}
int getInt(const string & prompt)
{
int i;
cout << endl <<prompt;
cin >> i;
return i;
}
//create appointment struct
struct appointment {
string description;
float date;
int duration;
string name;
};
const int limit= 100;
appointment appointments[limit];
int usedup=0;
int current=0;
appointment getAppointment()
{
appointment a;
a.name= getString("Please enter who the appointment is with: ");
a.description= getString("Enter a description for this appointment: ");
a.date= getFloat("Enter The date of the appointment (DD.MM): ");
a.duration= getInt("Please enter how long the appointment will take, in hours: ");
usedup++;
cout<< endl<<"Thank you, entry with appointmentID # " << usedup <<" added" <<endl;
return a;
}
void showAppDate(float x){
int i;
for (i=0;i<100;i++)
{
if (i.date == x)
{
cout <<endl<<"Appointment with: "<<i.name<<endl;
cout <<"Description: "<<i.description<<endl;
cout <<"Date: "<<i.date<<endl;
cout <<"Appointment duration: "<<i.duration<<" hours"<<endl;
}
}
}
int main(){
//clears it
appointments.clear();
int selection;
do{
int appnr;
float appdate;
cout << "1= Add Appointment" <<endl;
cout << "2= Display Appointment by ID" <<endl;
cout << "3= Display Appointment by DATE" <<endl;
cout << "4= Delete Appointment" <<endl;
cout << "5= Show All Appointments" <<endl;
cout << "6= Quit"<<endl;
cin >> selection;
cin.ignore();
switch (selection){
case 1:
getAppointment();
break;
case 2:
cout <<"Please enter which date the appointment is (DD.MM): ";
cin>> appdate;
showAppDate(appdate);
break;
}
while (selection< 6);
};