1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alex41 [277]
3 years ago
9

Your friend is an intern at the local Department of Health and needs to prepare a report about the recent activity of the influe

nza 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.
Computers and Technology
2 answers:
alekssr [168]3 years ago
6 0

Answer:

C code explained below

Explanation:

I have provided the proper commented code below.

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;

}

Butoxors [25]3 years ago
3 0

Answer:

#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;

}

Explanation:

You might be interested in
What would you need to have on your foley stage
LUCKY_DIMON [66]
<span>You will need many props for your Specific tracks (whatever you see in the film!). It's impossible to say what you will need until you see the picture and as time goes by you will add to your collection (if you have space!) - garbage day in my neighborhood is 'golden day' as I collect some of best props from the stuff people throw out: old bicycles, doors, sinks, wood, metal, desks, etc.</span>
4 0
3 years ago
Write and test a function that takes the addresses of three double variables as arguments and that moves the value of the smalle
damaskus [11]

Answer:

#include <bits/stdc++.h>

using namespace std;

// function to swap largest to third, smallest to first and middle to second

void valueSwap(double *a,double *b,double *c)

{

   // variables

  double f,s,t;

 // if value of first is greater than second

  if(*a>=*b)

  {

      // if value of first is greater than third

      if(*a>=*c)

      {

          // swap

          t = *a;

          if(*c>=*b)

          {

              s = *c;

              f = *b;

          }

          else

          {

              //swap

              f = *c;

              s = *b;

          }

      }

      else

      {

          //after all the swap

          f = *b;

          s = *a;

          t = *c;

      }

  }

  else

  {

      // if value of second is greater than third

      if(*b>=*c)

      {

          t = *b;

          if(*c>=*a)

          {

              // swap

              s = *c;

              f = *a;

          }

          else

          {

              //swap

              f = *c;

              s = *a;

          }

      }

      else

      {

          // after all the swap

          t = *c;

          s = *b;

          f = *a;

      }

  }

 

 // final values

  *a = f;

  *b = s;

  *c = t;

 

}

// main function

int main()

{

  // variables

  double n1,n2,n3;

  // ask to enter first number

  cout<<"Enter the first number:";

  // read first number

  cin>>n1;

  // ask to enter second number

  cout<<"Enter the second number:";

  // read second number

  cin>>n2;

  // ask to enter third number

  cout<<"Enter the third number:";

  // read third number

  cin>>n3;

  // call the function to swap values with address parameter

  valueSwap(&n1,&n2,&n3);

  // print number after swapping

  cout<<"Number after swapping: "<<n1<<" "<<n2<<" "<<n3<<endl;

  return 0;

}

Explanation:

Ask user to enter 3 double numbers.Then read 3 numbers from user and assign them  to variables "n1","n2" and "n3" respectively.Call the function valueSwap() which take address of all three variables as argument and then assign the largest value among the three to variable "n3" and smallest to "n1" and middle to variable "n2". Print the values after swapping.

Output:

Enter the first number:20                                                                                                  

Enter the second number:30                                                                                                

Enter the third number:10                                                                                                  

Number after swapping: 10 20 30

7 0
4 years ago
Binary divide 1101011 by 111​
denis-greek [22]

is this computer subject

5 0
3 years ago
Read 2 more answers
How do you print black and white on the ink Canon Pixma/TS3122?
Paha777 [63]

Answer:

If this printer can connect to a device wirelessly, then you can configure it through our mobile device. If not , try to click either the button above the yellow lights or below and see if that works.

5 0
3 years ago
Select the correct answer from each drop-down menu. Rita runs a small business that designs custom furnishings for corporate cli
LUCKY_DIMON [66]

Software as a Service cloud model is ideal for Rita’s business. SaaS are office solutions that allow Rita’s small business to work more efficiently and in a more organized way. Most SaaS applications are used for invoicing and accounting, sales, performance monitoring, and overall planning. SaaS applications can save Rita money. They do not require the deployment of a large infrastructure at her location. As a result, it drastically reduces the upfront commitment of resources. Whoever manages SaaS’s IT infrastructure running the applications brings down fees for software and hardware maintenance. SaaS has generally been acknowledged to be safer than most on-premise software.

5 0
3 years ago
Read 2 more answers
Other questions:
  • A receiver requires 10nW as input power. If all the system losses add up to 50dB, then how much power is required from the sourc
    15·1 answer
  • Fill in the missing statements or expressions in the following code that checks to ensure that a user enters an integer value at
    11·1 answer
  • Technician A says that automotive engine blocks are usually classified by the number of cylinders the block. Technician B says t
    9·1 answer
  • The proxy statement issued by a corporation is a requirement of: a. The Securities &amp; Exchange Commission (SEC) b. The Financ
    5·1 answer
  • The standard toolbar appears whenever you select text.
    5·1 answer
  • In c++
    12·1 answer
  • What is presentation software in bussiness used for
    9·1 answer
  • Moving your Sprite top to bottom is moving along the X coordinate?<br><br> True<br> False
    5·2 answers
  • Question 10 of 10
    15·1 answer
  • your organization has decided to use dhcp for ipv6. you want all windows 10 systems using ipv6 to get all of their tcp/ip inform
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!