C++
x
89
1
2
3
using namespace std;4
5
struct hiring6
{7
int cust_ID;8
string f_name;9
string l_name;10
string phone_number;11
string eqp_hire;12
string date_hire;13
string expected_return;14
};15
16
17
int main()18
{19
struct hiring cust[2];20
int i;21
int choice = 0;22
23
for (i = 0; i<2; i++){24
cout << endl; //taking values from user25
cout << "==================" << endl;26
cout << " Customer " << i + 1 << endl;27
cout << "==================" << endl;28
cout << endl;29
cout << "Enter customer ID: ";30
cin >> cust[i].cust_ID;31
cout << "Enter first name: ";32
cin >> cust[i].f_name;33
cout << "Enter last name: ";34
cin >> cust[i].l_name;35
cout << "Enter phone number: ";36
cin >> cust[i].phone_number;37
38
while (true){39
//cout << "\nSelect Equipment to be hired: ";40
41
cout << "\nSELECT FROM THE FOLLOWING OPTIONS: \n 1. Gardening Equipment\n 2. Building Equipment\n 3. Decorating Equipment\n 4. Car Maintenance\n 5. Miscellaneous\n ";42
cout << endl;43
cout << "Select equipment to be hired: ";44
cin >> choice;45
46
if (choice == 1){47
cust[i].eqp_hire = "Gardening Equipment";48
break;49
}50
else if (choice == 2){51
cust[i].eqp_hire = "Building Equipment";52
break;53
}54
else if (choice == 3){55
cust[i].eqp_hire = "Decorating Equipment";56
break;57
}58
else if (choice == 4){59
cust[i].eqp_hire = "Car Maintenance";60
break;61
}62
else if (choice == 5){63
cust[i].eqp_hire = "Miscellaneous";64
break;65
}66
else67
cout << "\nInvalid Option, try input again!!";68
choice = 0;69
}70
cout << "Enter date of hiring: ";71
cin >> cust[i].date_hire;72
cout << "Enter expected return date: ";73
cin >> cust[i].expected_return;74
}75
cout << endl;76
77
// Printing out value78
79
cout << "Customer ID: " << cust[0].cust_ID << endl;80
cout << "First Name: " << cust[0].f_name << endl;$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.76.0/gcc-11.1.0/include -std=gnu++2b
Stdin
123f_name_0l_name_0phone_number_01date_hire_0expected_return_0456f_name_1l_name_1phone_number_12date_hire_1expected_return_1Start
================== Customer 1 ================== Enter customer ID: Enter first name: Enter last name: Enter phone number: SELECT FROM THE FOLLOWING OPTIONS: 1. Gardening Equipment 2. Building Equipment 3. Decorating Equipment 4. Car Maintenance 5. Miscellaneous Select equipment to be hired: Enter date of hiring: Enter expected return date: ================== Customer 2 ================== Enter customer ID: Enter first name: Enter last name: Enter phone number: SELECT FROM THE FOLLOWING OPTIONS: 1. Gardening Equipment 2. Building Equipment 3. Decorating Equipment 4. Car Maintenance 5. Miscellaneous Select equipment to be hired: Enter date of hiring: Enter expected return date: Customer ID: 123 First Name: f_name_0 Last Name: l_name_0 Phone no: phone_number_0 Equipment to be hired: Gardening Equipment Date of hiring: date_hire_0 Expected return date: expected_return_0
0
Finish