Question

In: Computer Science

Problem: Your friend is an intern at the local Department of Health and needs to prepare...

Problem: Your friend is an intern at the local Department of Health and needs to prepare a report about the recent activity of the influenza virus. She has recorded the number of cases of each type of flu (A, B, and C) over the last several weeks. Write a C++ program that will calculate the total cases for each week, determine the level of activity for the week (low, moderate, or widespread) and print a report to a file, including a small bar chart for the weekly cases.

Input: The user should be prompted to input the total number of weeks, and then for each week the number of cases of type A, B, and C flu reported.

Processing: For each week, sum up the total number of flu cases. Also sum up the total number of cases of flu reported over the entire period.

Output: The program should output a report to a file named “flu_report.txt”. The first row of the report should be a list of column headers that label the data to be output. This should be followed by a row for each week that lists the week number and the number of total cases of flu. This should be followed by the activity rating: “Low” if the total cases are less than than 500. Otherwise “Moderate” if the cases are less than 2000, and “Widespread” if the total cases are 2000 or more. This should be followed by an asterisk for each 250 cases of the total weekly cases. After the table is complete, the program should output the total number of flu cases for the entire period. See a sample below:

Week Total Cases Activity Chart

1 333 Low   |*

2 1079 Moderate |****

3 2497 Widespread |*********

4 1830 Moderate |*******

------------------------------------------------------------------

The total number of cases reported: 5739

Solutions

Expert Solution

I have provided the proper commented code with proper screenshots so that you may indent it properly.

I hope that you find the answer helpful.

CODE:

-------------------------------------------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std;

int main(){
   // Defining Variables
   int no_of_weeks;
   int total_cases = 0;
   //Declaring Vector of Pair of Integer and string
   std::vector<pair<int,string>> data;
   // Taking Input for the Number of Weeks
   cout<<"Enter No. of Weeks\n";
   cin >> no_of_weeks;
   // Running the Loop for no_of_weeks times
   for(int i = 0; i < no_of_weeks ; i++){
       int A,B,C;
       // Taking Input for different types of flus
       cout<<"Enter No. of Cases of Flu A, B, C for week" << i + 1 << " seperated by space : \n";
       cin >> A >> B >>C;
       // Adding all the cases in a week
       int cases_in_a_week = A + B + C;
       // Updating total cases
       total_cases += cases_in_a_week;
       // Declaring the level variable
       string level;
       // Updating the level of the week corresponding to each case
       if(cases_in_a_week < 500) level = "Low";
       else if(cases_in_a_week >= 500 && cases_in_a_week < 2000) level = "Moderate";
       else level = "Widespread";
       // Storing the Week's information by using a vector of pairs
       // in which pair's first is the number of cases which is of type int
       // while the second is the level of the flu which is of the type string
       data.push_back(make_pair(cases_in_a_week,level));
   }
   // Linking the stdoutput to the flu_report.txt file
   // this also creates the file with the same name if it doesn't exists
   freopen("flu_report.txt", "w", stdout);
   // Printing the respective output data with Bar Chart of stars for each level
   for(int i = 0;i < no_of_weeks ; i++){
       //printing the week no. and number of cases
       cout<<i+1<<" "<<data[i].first<<" "<<data[i].second<<" |";
       //calculating the number of stars
       int stars = data[i].first/250;
       //printing the stars of the bar chart
       for(int j = 0; j < stars ; j++) cout<<"*";
       cout<<endl;
   }
   //printing the total number of cases
   cout<<total_cases;
}

-------------------------------------------------------------------------------------------------------------

Screenshots:

-------------------------------------------------------------------------------------------------------------

Code:

Compilation and Running:

You can Compile the code using command "g++ filename.cpp" without quotes and run the same using "./a.out"

Output:

I hope you find the answer useful.

Happy Coding !


Related Solutions

You are an intern at the health department of your city. An outbreak of coronavirus has...
You are an intern at the health department of your city. An outbreak of coronavirus has been detected in a hotel in your city. 10 guests are infected. You must decide whether to quarantine the hotel or not. There are 1000 guests in the hotel. From previous experience, we know that at least half of them will be infected if the quarantine goes in to effect. If there is no quarantine the virus will spread more rapidly to the general...
Your assignment is to imagine you’re in charge of your local public health department for your...
Your assignment is to imagine you’re in charge of your local public health department for your community. Your department has the chance to apply for funding under the umbrella of the WHO Essential Public Health Function (EHPF) framework to fund one public health issue in your community. What public health issue will you address, and what intervention will you design? In your paper, be sure to address: ·        The public health issue and its impact on health - make your...
You are an MPH student intern in a local church. Part of your assigned tasks is...
You are an MPH student intern in a local church. Part of your assigned tasks is to research the possibility of getting a grant to fund a new Head Start preschool program in the church. You find out the following: You are planning a weight control program in your church. You have assessed the need and interest; you have identified program goals and outcomes; you have selected resources and materials; all you have left to do is plan the evaluation....
What are the 10 Local Health Department (LHD) standards?
What are the 10 Local Health Department (LHD) standards?
Visit your local health department either in person or via their website and find out how...
Visit your local health department either in person or via their website and find out how it is structured. In addition, please describe how the department in addressing a local health issue. Document your findings as a 250 word essay that includes the following information: •What is the structure of the department, organizational chart •List the activities and services of the department •Give details of one of their programs
Visit your local health department either in person or via their website and find out how...
Visit your local health department either in person or via their website and find out how it is structured. In addition, please describe how the department in addressing a local health issue. Document your findings as a 250 word essay that includes the following information: •What is the structure of the department, organizational chart •List the activities and services of the department •Give details of one of their programs
Your local public health department is considering expanding its free vaccination services to reach more of...
Your local public health department is considering expanding its free vaccination services to reach more of the population, particularly underserved populations that are currently vaccinated at lower rates. You have been tasked with completing a cost-benefit analysis. Which benefits and costs would you include? How would you measure them?
Imagine that you are a government official in a local health department, in charge of an...
Imagine that you are a government official in a local health department, in charge of an immunization program that provides free immunizations to all uninsured children in your county. The County Board of Supervisors (which is in charge of all county health care related matters, and funds your department) has asked you to justify your program's budget by demonstrating that your program has made significant progress over the past two years, increasing the immunization rates of low-income children in the...
What is the role of the local health department in the healthcare system? Write about the...
What is the role of the local health department in the healthcare system? Write about the health department in area where you live, what new projects does the department involve. Write between 500-700 words.
You land a job with the Health Department to assess your county’s obesity problem through intervention....
You land a job with the Health Department to assess your county’s obesity problem through intervention. Your employer wants you to hold community screenings that assess obesity values. You have 4 hours to screen as many people as possible. Name 2 measures that would be appropriate to use to assess obesity. Why did you choose these measures? Are they based on evidence and if so, explain what criteria/ cutpoints you are looking for? What are the pros for choosing these...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT