Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please debug #include using namespace std; // function prototypes void display_Question(); void yes_No(char); int get_Status(char, char); // start main function int main() { char red_zone,

Please debug
#include
using namespace std;
// function prototypes
void display_Question();
void yes_No(char);
int get_Status(char, char);
// start main function
int main() {
char red_zone, close_contact, fever; // two possible character values only: 'y' -> yes, 'n' -> no
int status; // 0 -> GREEN, 1 -> YELLOW, 2 -> ORANGE, 3 -> RED
for (int i = 1; i < 3; i++) {
display_question(i);
if (i == 1)
yes_No(red_zone); // set red_zone either 'y' or 'n'
else if (i == 2)
yes_No(close_contact); // set close_contact either 'y' or 'n'
else
yes_No(fever); // set fever either 'y' or 'n'
}
// get risk status based on red_zone, close_contact, fever parameters
status = get_Status(red_zone, close_contact, fever);
cout << "Your Covid-19 risk status is ";
switch (status) {
case 0: cout << "GREEN"; break;
case 1: cout << "YELLOW"; break;
case 2: cout << "ORANGE";
case 3: cout << "RED";
}
cout << " ";
return 0;
}
// start new user-defined functions
void display_Question(int q) {
switch (q)
case 1: cout << "Living in red zone? "; break;
case 2: cout << "Have a close contact with Covid-19 patient? "; break;
case 3: cout << "Body temperature >= 38 degrees Celcius? ";
}
}
void yes_No(char ans) {
do {
cout << "Please enter your answer (y / n): ";
cin >> ans;
} while (ans == 'n' && ans == 'y');
cout << ' ';
}
void get_Status(char rz, char cc, char f) {
int s = 0;
if (rz == 'y') s++;
if (cc == 'y') s++;
if (f == 'y') s++;
return s;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions