Re: CS201 Assignment 2 Solution and Discussion
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
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
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.
Write a menu in C++ which should show the state code and name of winning states at the start of application:
Press 1 for Florida.
Press 2 for Georgia.
Press 3 for Michigan.
Press 4 to exit.
(Use two dimensional array to store following data)
Joe Biden Votes
Donald Trump Votes
Jo Jorgensen Votes
[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
Percentage of Joe Biden votes
PercentageBiden ( ):
Percentage of Donald Trump votes
Percentage of Jo Jorgensen
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.