0% found this document useful (0 votes)
30 views5 pages

Assignment Submitted in Any Other Format Will Not Be Accepted and Will Be Graded Zero Marks

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views5 pages

Assignment Submitted in Any Other Format Will Not Be Accepted and Will Be Graded Zero Marks

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment No.

2 Total Marks: 20
Semester: Fall 2020 Due Date:
CS201 – Introduction to Programming 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.

Copyright © Virtual University of Pakistan


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 Donald Trump Jo Jorgensen Total Votes


Joe Biden Votes Votes 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();

Copyright © Virtual University of Pakistan


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.

Copyright © Virtual University of Pakistan


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:

Copyright © Virtual University of Pakistan


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.

Copyright © Virtual University of Pakistan

You might also like