Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

CS201 Introduction to Programming Assignment No 02 Fall 2020 Solution / Discussion Due Date: 18-12-2020

CS201 Introduction to Programming Assignment No 02 Fall 2020 Solution / Discussion Due Date: 18-12-2020

Assignment No.  2
Semester: Fall 2020

CS201 – Introduction to Programming

Total Marks: 20

Due Date: 18-12-2020

Instructions

Please read the following instructions carefully before submitting the assignment:

It should be clear that your assignment will not get any credit if: 

o        Assignment is submitted after due date.

o        Submitted assignment does not open or file is corrupt.

o        Assignment is copied (From internet/students).

 

Software allowed to develop Assignment

      Dev C++

 

Objectives:

In this assignment, the students will learn:

  • How to fill / populate a two-dimensional array using given source data.
  • How to write user defined functions and pass an array to them as parameter.
  • How to use if statement and do while loop.
  • How to calculate the percentage in elements of array.
  • How to display array elements.

 

Assignment Submission Instructions

You are required to submit only .cpp file on the assignments interface of CS201 at VU-LMS. Assignment submitted in any other format will not be accepted and will be graded zero marks. 

   
       

  

As all of you know that presidential election was conducted in USA recently, and the entire world had an eye on the results. There were three main candidates; Donald Trump from Republicans party, Joe Biden from Democrats and Jo Jorgensen as an independent candidate. Though the strong candidates for this presidential election 2020 were Trump and Biden, and there was tough competition among them. Similarly, some states of USA have played the role of Crucial states (Winning states) to win the election. In this assignment you will be provided with data from USA election 2020 and you have to write C++ program according to the given data.

Problem Statement

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

    1. Press 1 for Florida.
    2. Press 2 for Georgia. 
    3. Press 3 for Michigan.
    4. Press 4 to exit.

Source data:

(Use two dimensional array to store following data)

State Code

Joe Biden Votes

Donald Trump Votes

Jo Jorgensen Votes

Total Votes

1

5,284,453

5,658,847

70,046

11,013,346

2

2,465,781

2,455,428

61,894

4,983,103

3

2,790,648

2,644,525

60,287

5,495,460

                                                                                                                                     [above dummy data is for assignment purpose only]

Instructions to write C++ program:

 

Ø  Write functions to calculate %age of Joe Biden votes, %age of Donald Trump votes and %age of Jo Jorgensen votes in specific State. Following function names should be used for consistency.

 

To display all data in matrix form

showElements( );

Percentage of Joe Biden votes

PercentageBiden ( ):

Percentage of Donald Trump votes

PercentageTrump();

Percentage of Jo Jorgensen

PercentageJorgensen();

 

Sample Output:

First, user will call the showElements() method to display all the source data in matrix form. Then, it will display a menu to calculate the percentage of Biden, Trump and Jorgensen votes for specific state:

 

 

If user presses 1 then it will show the percentage of Biden, Trump and Jorgensen votes from state Florida.

 

 

 

If user presses 2 then it will show the percentage of Biden, Trump and Jorgensen votes from state Georgia.

 

 

Similarly, If user presses 3 then it will show the percentage of Biden, Trump and Jorgensen votes from state Michigan.

 

If the user enters option other then 1 to 4. Following messages display:

Choice should be between 1 and 4

Invalid choice, please select again:

 

Wish you Good Luck!

 

Lectures Covered:  This assignment covers Lecture # 07-15.

Deadline: The deadline to submit your assignment solution is 18-12-2020. Your assignment must be submitted within the due date through VU-LMS. No assignment will be accepted through email after the due date.

Views: 1606

Replies to This Discussion

Share the Assignment Questions & Discuss Here.... 

cs201 assignment no 02 solution fall 2020

Click on the below link to download the file

CS201_Assignment_No_02_Solution_Fall_2020

cs201 solution assignment no 02 fall 2020

Click on the below link to download the file

Fall 2020_CS201_2_BC190202364

CS201 2nd Assignment Solution.....

you can download the assignment in different format

  1. cs201 assignment 2 solution 2020 pdf
  2. cs201 assignment 2 solution 2020 download
  3. cs201 assignment 2 solution file
  4. cs201 assignment 2 solution 2020 pdf download
  5. cs201 assignment 2 solution fall 2020
  6. cs201 assignment 2 download
  7. cs201 assignment 2 solution fall 2020
  8. cs201 assignment 2 solution 2020

CS201 Assignment 2 Solution Fall 2020

#include <iostream>

#include <stdlib.h>

#include <conio.h>

using namespace std;

//

void showElements();

void PercentageBiden ();

void PercentageTrump();

void PercentageJorgensen();

void line();

 

float per[4];                                      

unsigned long vote[3][5]={

                                                                                                                { 1, 5284453, 5658847, 70046, 110133462},

                                                                                                                { 2, 2465781, 2455428, 61894, 4983103},

                                                                                                                { 3, 2790648, 2644525, 60287, 5495460},

                                                                                                                };

int main()

{

                int option;

                                cout"\tAssignment Solved by Abdul Hadi E Services" endl;

                showElements();

                opt:

                {

                                Opt:                                      

                                                {

                                                                cout"\n\nPress the states code to calcalculate percentage of Trum, Biden and Jorgensen Votes"endl;

                                                                cout"Press 1 for Florida."endl;

                                                                cout"Press 2 for Georgia."endl;

                                                                cout"Press 3 for Michigan."endl;

                                                                cout"Press 4 for Exit."endl;

                                                                cout"\n\nPlease Select an Option, use numbers from 1 to 4 :   ";

                                                                cin>>option;

                                                }

                switch(option)

                {

                                case 1:

                                                line();

                                                PercentageBiden ();

                                                {

                                                                cout"\nPercentage of Jo Biden votes is: "per[1]endl;

                                                                cout"\nPercentage of Donald Trump votes is: "per[2]endl;

                                                                cout"\nPercentage of Jo Jorgensen votes is: "per[3]endl;

                                                                goto opt;

                                                }

                                                break;

                                case 2:

                                                line();

                                                PercentageTrump();

                                                                {

                                                                cout"\nPercentage of Jo Biden votes is: "per[1]endl;

                                                                cout"\nPercentage of Donald Trump votes is: "per[2]endl;

                                                                cout"\nPercentage of Jo Jorgensen votes is: "per[3]endl;

                                                                goto opt;

                                                                }

                                                break;

                                                case 3:

                                                                line();

                                                                PercentageJorgensen();

                                                                {

                                                                cout"\nPercentage of Jo Biden votes is: "per[1]endl;

                                                                cout"\nPercentage of Donald Trump votes is: "per[2]endl;

                                                                cout"\nPercentage of Jo Jorgensen votes is: "per[3]endl;

                                                                goto opt;

                                                                }

                                                break;

                                                case 4:

                                                                return(0);

                                                                break;

                                                default:

                                                                {

                                                                                cout"\n\nChoice should be Between 1 to 4 " endl;

                                                                                cout"\nInvalid Choice, Please Select again: " endl;

                                                                                goto opt;

                                                                }

                }

                                system ("Pause");

                }

}

//Showing all data in arr

void showElements()

                {

                                int b,c;

                                cout"\nSource Data:\nStates\t\tBiden Votes\tTrump Votes\tJorgensen Votes\tTotalVotes\n";

                                for (b=0; b<3; b++)

                                {

                                                for (c=0; c<5; c++)

                                                coutvote[b][c]"\t\t";

                                                coutendl;

                                }

                }

void PercentageBiden()

                {

                                int b;

                                for (b=1; b<4; b++)

                                per[b]=float(vote[0][b])/11013346.0*100;

                }

void PercentageTrump()

                {

                                int b;

                                                for (b=1; b<4; b++)

                                                per[b]=float(vote[1][b])/4983103.0*100;

                }

void PercentageJorgensen()

                {

                                int b;

                                                for (b=1; b<4; b++)

                                                per[b]=float(vote[2][b])/5495460.0*100;

                }

void line()

{

                cout"\n--------------------------------------------";

}

 

In this programme have lot off errorrs 

this programe not compile 

plese remove the errorrs ,then upload

#cs201assignment2solutionfall2020 #cs201assignment2solution2020
CS201 Assignment 2 Solution Fall 2020 | CS201 Assignment Solution 2020

CS201 Assignment 2 Solution Fall 2020 | CS201 Assignment Solution 2020

cs201 assignment no 02 solution fall 2020

Click on the below link to download the file

CS201_Assignment_No_02_Solution_Fall_2020

#include <iostream>

using namespace std;

void showElements(int data[][5] ){
int i = 0;
int rows = 3, cols = 5;
cout“Source data:”endlendl;
cout“States Biden Votes Trump Votes Jorgensen Votes Total Votes”;
coutendlendl;
for(i; i < rows; i++){
int j = 0;
for(j; j < cols; j++){
coutdata[i][j]” \t”;
if(j == cols – 2){
cout“\t”;
}
}
coutendl;
}
}

double PercentageBiden(int data[][5], int state){
return (double)data[state][1] * 100 / (double)data[state][5 – 1];
}

double PercentageTrump(int data[][5], int state){
return (double)data[state][2] * 100 / (double)data[state][5 – 1];
}

double PercentageJorgensen(int data[][5], int state){
return (double)data[state][3] * 100 / (double)data[state][5 – 1];
}

void ShowMenu(){
coutendl;
cout“Press the state code to calculate percentage of Trum, Biden and Jorgenson votes”;
coutendlendl;
cout“Press 1 for Florida.”endl;
cout“Press 2 for Georgia.”endl;
cout“Press 3 for Michigan.”endl;
cout“Press 4 for exit”endlendl;
}

void showStateWisePercentage(int data[][5], int state){
coutendl;
cout“Percentage of Joe Biden Vites is: “PercentageBiden(data, state)endl;
cout“Percentage of Joe Biden Vites is: “PercentageTrump(data, state)endl;
cout“Percentage of Joe Biden Vites is: “PercentageJorgensen(data, state)endl;
}

int main(){

int data[3][5] = {
{1, 5284453, 5658847, 70046, 11013346},
{2, 2465781, 2455428, 61894, 4983103},
{3, 2790648, 2644525, 60287, 5495460}
};

showElements(data);

int ch;

do{
ShowMenu();

cout“Please select an option, use numbers from 1 to 4: “;
cin>>ch;
if(ch < 1 || ch > 4){
cout“Choice should be between 1 and 4″endl;
cout“Invalid choice, please select again: “;
cin>>ch;
}
switch(ch){
case 1:
showStateWisePercentage(data, 0);
break;
case 2:
showStateWisePercentage(data, 1);
break;
case 3:
showStateWisePercentage(data, 2);
break;
}

}while(ch != 4 );

}

01cs201 2020cs201 assignmentcs201 assignment 2cs201 assignment 2 solutioncs201 assignment 2 solution 2020cs201 assignment 2 solution spring 2020cs201 assignment 2 spring 2020cs201 assignment 2020cs201 assignment no 2 solution 2020cs201 assignment no 2 solution spring 2020cs201 assignment no. 2cs201 assignment no. 2 spring 2020CS201 ASSIGNMENT NO2CS201 ASSIGNMENT NO2 SOLUTION 2020CS201 ASSIGNMENT NO2 SOLUTION FALL 2020cs201 assignment solutioncs201 assignment solution 2CS201 ASSIGNMENTNO2cs201 pdfcs201 short notescs201 solutioncs201 solved file

CS201 Assignment 2 solution fall 2020

#include <iostream>

using namespace std;

void showElements(int data[][5] ){
int i = 0;
int rows = 3, cols = 5;
cout"Source data:"endlendl;
cout"States Biden Votes Trump Votes Jorgensen Votes
Total Votes";
coutendlendl;
for(i; i < rows; i++){
int j = 0;
for(j; j < cols; j++){
coutdata[i][j]" \t";
if(j == cols - 2){
cout"\t";
}
}
coutendl;
}
}

double PercentageBiden(int data[][5], int state){
return (double)data[state][1] * 100 / (double)data[state][5 - 1];
}

double PercentageTrump(int data[][5], int state){
return (double)data[state][2] * 100 / (double)data[state][5 - 1];
}

double PercentageJorgensen(int data[][5], int state){
return (double)data[state][3] * 100 / (double)data[state][5 - 1];
}

void ShowMenu(){
coutendl;
cout"Press the state code to calculate percentage of Trum,
Biden and Jorgenson votes";
coutendlendl;
cout"Press 1 for Florida."endl;
cout"Press 2 for Georgia."endl;
cout"Press 3 for Michigan."endl;
cout"Press 4 for exit"endlendl;
}

void showStateWisePercentage(int data[][5], int state){
coutendl;
cout"Percentage of Joe Biden Vites is: "PercentageBiden(data, state)endl;
cout"Percentage of Joe Biden Vites is: "PercentageTrump(data, state)endl;
cout"Percentage of Joe Biden Vites is: "PercentageJorgensen(data, state)endl;
}

int main(){

int data[3][5] = {
{1, 5284453, 5658847, 70046, 11013346},
{2, 2465781, 2455428, 61894, 4983103},
{3, 2790648, 2644525, 60287, 5495460}
};

showElements(data);

int ch;

do{
ShowMenu();

cout"Please select an option, use numbers from 1 to 4: ";
cin>>ch;
if(ch < 1 || ch > 4){
cout"Choice should be between 1 and 4"endl;
cout"Invalid choice, please select again: ";
cin>>ch;
}
switch(ch){
case 1:
showStateWisePercentage(data, 0);
break;
case 2:
showStateWisePercentage(data, 1);
break;
case 3:
showStateWisePercentage(data, 2);
break;
}

}while(ch != 4 );

}

cs201 assignment 2 solution cs201 assignment 2 solution fall 2020 cs201 assignment solution fall 2020

#cs201 #cs201Assignment
CS201 Assignment2 solution 2020 | Virtual University

RSS

Looking For Something? Search Below

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service