197 views

Hello guyz, CS201 Assignment No.2 Solution is required. The problem statement is here

Write a menu in C++ which should show the country code and name at the start of application:

1. Press 0 for Pakistan.
2. Press 1 for China.
3. Press 2 for Italy.
4. Press 3 for UK.
5. Press 4 for Iran.
6. Press 5 for France.
7. Press 6 for Turkey.
8. Press 7 to exit.

Tags: CS201 Assignment No.2 Solution
CS201 Assignment No.2 Solution 2020
CS201 Assignment No.2 Solution Spring 2020
CS201 Assignment 2 Solution
CS201 Assignment 2 Solution 2020
CS201 Assignment 2 Solution Spring 2020
CS201 Assignment 2 2020 Solution
CS201 Assignment 2 Spring 2020 Solution
CS201 Assignment 2 2020
CS201 Assignment No 2 Solution
CS201 Assignment No 2 Solution 2020
CS201 Assignment No 2 Solution Spring 2020
CS201 Assignment No 2 2020 Solution
CS201 Assignment No 2 Spring 2020 Solution
CS201 Assignment No 2 2020

| 197 views

Here is the solution:

``````#include<iostream>
using namespace std;

void showElements(long s[][4]);
void PercentageDeath(long s[][4], int i);
void PercentageRecovered(long s[][4], int i);

main()
{
long source_data[7][4]= {0,560433, 22115, 32634, 1,156363, 19899, 34211, 2,84279, 10612, 0, 3,82160, 3341, 77663, 4,71686, 4474, 43894, 5,56956, 1198, 3446, 6,5374, 93, 109};
showElements(source_data);
int user_choice;
do
{
cout<<"\nPress the country code to calculate percentage of dead and recovered persons\n";
cout<<"\n*** Press 0 for Pakistan ***";
cout<<"\n*** Press 1 for China ***";
cout<<"\n*** Press 2 for Italy ***";
cout<<"\n*** Press 3 for UK ***";
cout<<"\n*** Press 4 for Iran ***";
cout<<"\n*** Press5 for France ***";
cout<<"\n*** Press 6 for Turkey ***";
cout<<"\n*** Press 7 to Exit ***";
cout<<"\n\nPlease select an option use number from 0 to 7 : ";
input:
cin>>user_choice;
if(user_choice>=0 && user_choice<=6)
{
PercentageDeath(source_data, user_choice);
PercentageRecovered(source_data, user_choice);
}
else if(user_choice<0 || user_choice>7)
{
cout<<"\n\nChoice should be between 0 to 7 ";
cout<<"\ninvalid choice ! please select again : ";
goto input;
}
}while(user_choice!=7);
}

void showElements(long s[][4])
{
cout<<"Source Data : \n\n";
cout<<"Country\tCases\tDeaths\tRecovered\n\n";
for(int i=0; i<7; i++)
{
for(int j=0; j<4; j++)
{
cout<<s[i][j]<<"\t";
}
cout<<"\n";
}
}

void PercentageDeath(long s[][4], int i)
{
float d_rate=(float)100*s[i][2]/s[i][1];
cout<<"\nPercentage of death is "<<d_rate;
}

void PercentageRecovered(long s[][4], int i)
{
float r_rate=(float)100*s[i][3]/s[i][1];
cout<<"\n\nPercentage of recocered is "<<r_rate<<"\n";
}
``````
by (3.3k points)
what is execute and parameters can you please let me know
simply, copy it and paste into Dev C++ and execute it!
If you get any error, then comment me here

+1 vote