Cs201 Assignment 2 Solution Fall 2020

0
26
Cs201 Assignment 2 Solution Fall2020
  1. Assignment No.  2
    Semester: Fall 2020

Cs201 Assignment 2 Solution Fall2020

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:

 

Assignment is submitted after due date.

Submitted assignment does not open or file is corrupt.

Assignment is copied (From internet/students).

 

Software allowed to develop Assignment

 

–          Dev C++

 

Objectives:

In this assignment, the students will learn:

  1. How to fill / populate a two-dimensional array using given source data.
  2. How to write user defined functions and pass an array to them as parameter.
  3. How to use if statement and do while loop.
  4. How to calculate the percentage in elements of array.
  5. 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.

 

 

Cs201 Assignment 2 Solution Fall 2020

Click Here 

 

 

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 for Florida.

2 for Georgia.

3 for Michigan.

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.

Cs201 Assignment 2 Solution Fall 2020

Click Here 

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();

  

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:

Cs201 Assignment 2 Solution Fall 2020

Click Here 

Wish you Good Luck!