i was confuse what my professor say. What is the answer? First review the code a
ID: 3869809 • Letter: I
Question
i was confuse what my professor say. What is the answer?
First review the code and submit the screen output for the attached CPP source code by creating six patient objects for the following people:
1) A 33-year-old woman, non-smoker with normal blood pressure who eats a high fat diet.
2) A 19-old-year man, non-smoker with high blood pressure who eats a high fat diet.
3) A 50-old-year woman, non-smoker with high blood pressure who eats a high fat diet.
4) A 27-year-old man, smoker with high blood pressure who eats a low fat diet.
5) A 43-year-old woman, smoker with high blood pressure who eats a high fat diet.
6) A 17-year-old woman, non-smoker with normal blood pressure who eats a high fat diet.
using namespace std;
void DisplayMenu();
int GetChoice();
bool Confirm();
void ProcessChoice(int);
int main()
{
int choice;
bool quit = false;
do
{
DisplayMenu();
choice = GetChoice();
if (choice == 0)
{
if (Confirm())
quit = true;
}
else
ProcessChoice(choice);
} while (!quit);
return 0;
}
void DisplayMenu()
{
cout << "1) Enter new patient ";
cout << "2) List all smokers ";
cout << "3) List all Male smokers ";
cout << "4) List all Female smokers ";
cout << "5) List all with risk factor greater than 5 ";
cout << "6) List all with risk factor less than 5 ";
cout << "7) Search by SS number ";
cout << "8) List all by an age ";
cout << "9) List all with HBP and HFD ";
cout << "10) List Counts of Smokers, HFD, and HBP ";
cout << "0) Exit ";
}
int GetChoice()
{
int choice;
cout << " Enter a choice ";
cin >> choice;
return choice;
}
bool Confirm()
{
char choice = 'N';
bool rsp = false;
bool done = false;
do
{
cout << " Are you sure to quit (Y/N)? ";
cin >> choice;
choice = toupper(choice);
if (choice == 'Y')
rsp = true;
if (choice == 'Y' || choice == 'N')
done = true
;else
done = false;
} while (!done);
return rsp;
}
void ProcessChoice(int c)
{
switch (c)
{
case 1:
//Enter_new_patient();
break;
case 2:
//List_all_smokers();
break;
case 3:
//List_all_Male_smokers();
break;
case 4:
//List_all_Female_smokers();
break;
case 5:
//List_risk_factor_GT5();
break;
case 6:
//List_risk_factor_LT5();
break;
case 7:
//Search_SS();
break;
case 8:
//List_by_age();
break;
case 9:
//List_all_HBP_HFD();
break;
case 10:
//Exit_app();
break;
default:
cout << "Incorrect choice. ";
}
}
Explanation / Answer
This is an incomplete program, No proper code is there it is much like dummy program. It just displays the content on screen no way is there to process it, takes the input. There is flaw in program. Instructtor might want to complete it, but It can't now as it does not have instruction what code do. So this is an incomplete program one can't give input to it and expect that it will give you desired output.
Program need to add many things as you can cleaely see there is no action statement in switch case, and nowhere pateint name etc is able to cin, so it id concluded that it is an incomplete program you can give this inputs to it.It just keep on displaying same data or on entering 0 it exit.
To clarify a few comments are added at neccesary functions.
#include <iostream>
using namespace std;
void DisplayMenu();
int GetChoice();
bool Confirm();
void ProcessChoice(int);
int main()
{
int choice;
bool quit = false;
do
{
DisplayMenu();
choice = GetChoice();
if (choice == 0)
{
if (Confirm())
quit = true;
}
else
ProcessChoice(choice);
} while (!quit);
return 0;
}
void DisplayMenu() // It is just displaying on screen that eneter but in the code nothing is there which taked input and process it.
{
cout << "1) Enter new patient ";
cout << "2) List all smokers ";
cout << "3) List all Male smokers ";
cout << "4) List all Female smokers ";
cout << "5) List all with risk factor greater than 5 ";
cout << "6) List all with risk factor less than 5 ";
cout << "7) Search by SS number ";
cout << "8) List all by an age ";
cout << "9) List all with HBP and HFD ";
cout << "10) List Counts of Smokers, HFD, and HBP ";
cout << "0) Exit ";
}
int GetChoice()
{
int choice;
cout << " Enter a choice ";
cin >> choice;
return choice;
}
bool Confirm()
{
char choice = 'N';
bool rsp = false;
bool done = false;
do
{
cout << " Are you sure to quit (Y/N)? ";
cin >> choice;
choice = toupper(choice);
if (choice == 'Y')
rsp = true;
if (choice == 'Y' || choice == 'N')
done = true
;else
done = false;
} while (!done);
return rsp;
}
void ProcessChoice(int c) // Code is incomplete here nothing is added on what if input is triggered
{
switch (c)
{
case 1:
//Enter_new_patient();
break;
case 2:
//List_all_smokers();
break;
case 3:
//List_all_Male_smokers();
break;
case 4:
//List_all_Female_smokers();
break;
case 5:
//List_risk_factor_GT5();
break;
case 6:
//List_risk_factor_LT5();
break;
case 7:
//Search_SS();
break;
case 8:
//List_by_age();
break;
case 9:
//List_all_HBP_HFD();
break;
case 10:
//Exit_app();
break;
default:
cout << "Incorrect choice. ";
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.