2. University AAA has 150 staff which consists of an academic and a non-academic category. Each staff is given an option to select either a PENSION ON 56 YEARS scheme or a PENSION ON 60 YEARS scheme. Display the details of each staff information and the total number of academic staff and non-academic staff that have selected a PENSION ON 56 YEARS scheme and a PENSION ON 60 YEARS scheme. You are required to get an output as shown in Figure B. Staffs' Information Name NOIC Age Category Scheme .. .. Report of selected Scheme Category Academic PENSION 56 : .... PENSION 60 : .... Report of selected Scheme Category Non-Academic PENSION 56 : .... PENSION 60 : ....
Help me solve my coding. I almost could run it.
I provided to you the question.
#include <iostream>
#include <string>
using namespace std;
struct staff
{
string name;
int ic;
int age;
int category;
int scheme;
};
int *p;
int *q;
int *r;
int *t;
int ac_56, ac_60, nonac_56, nonac_60;
int main ()
{
for(int i=0; i<2; i++)
{
cout << "name: ";
getline(cin, staff[i].name);
cout <<"ic: ";
cin >> staff[i].ic;
cin.ignore();
cout << "age: ";
cin >> staff[i].age;
cin.ignore();
cout << "category (1-academic @ 2-nonacademic): ";
cin >> staff[i].category;
cin.ignore();
cout << "scheme (1-56 @ 2-60): ";
cin.ignore();
if(staff[i].category = 1 && staff[i].scheme = 1)
{
p = ac_56;
p++;
}
else if (staff[i].category = 1 && staff[i].scheme = 2)
{
q = ac_60;
q++;
}
else if (staff[i].category = 2 && staff[i].scheme = 1)
{
r = nonac_56;
r++;
}
else if (staff[i].category = 2 && staff[i].scheme = 2)
{
t = nonac_60;
t++;
}
else
{
cout << "lol tol tol lah.";
}
}
for (int i=0; i<2; i++)
{
cout <<"name"<<"\t\t"<<"ic"<<"\t\t"<<"age"<<"\t\t"<<"category"<<"\t\t"<<"scheme"<<endl;
cout << staff[i].name<<"\t\t"<<staff[i].ic<<"\t\t"<<staff[i].age<<"\t\t"<<staff[i].category<<"\t\t"<<staff[i].scheme<<endl;
}
for (int i=0; i<2; i++)
{
cout << "\n\nreported selected scheme"<<endl;
cout << "\ncategory academic:"<<endl;
cout << "\tpension 56: " << *p << endl;
cout << "\tpension 60: " << *q <<endl;
cout << "\ncategory nonacademic:"<<endl;
cout << "\tpension 56: " << *r << endl;
cout << "\tpension 60: " << *t <<endl;
}
}
Step by step
Solved in 2 steps with 1 images