Quiz 100% Result

  • 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
    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:
    Press 1 for Florida.
    Press 2 for Georgia.
    Press 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.

    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.

  • Cyberian's Gold

    @asma-zahid said in CS201 Assignment 2 Solution and Discussion:

    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
    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:
    Press 1 for Florida.
    Press 2 for Georgia.
    Press 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.

    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.

    #include <iostream>
    #include <time.h>
    #include <stdlib.h>
    using namespace std;
    
    const int rows = 3; 
    const int cols = 5;
    
    int selectOption(){
    	int choice = 0;	
        cout << "Press the state code to calculate percentage of Trum, Biden and Jorgensen votes\n\n" ;
    	
    	cout<<"Press 1 for Florida.\n";
    	cout<<"Press 2 for Georgia.  \n";
    	cout<<"Press 3 for Michigan.\n";
    	cout<<"Press 4 To Exit\n";
    	
    	
    	cout<<"\nPlease select an option, use numbers from 1 to 4: ";
    	
    	do {
    		cin>>choice;
    		if(choice >= 0 && choice <= 4){
    			break;
    		}
    		else {
    			cout<<"\nChoice should be between 1 and 4\n";
    			cout<<"Invalid choice, please select again: ";
    		}
    	} while(true);
    	cout<<"___________________________________________________\n";
    	return choice -1;	
    } // end selectOption function
    
    
    
    void showElements(int data[][5]){
        cout << "Source Data:" << endl << endl ;
    	cout << "States" "\t"<< "\t""\Biden Votes" << "\t" "\Trump Votes" << "\t""\Jorgensen Votes" << "\t" "\Total Votes" << endl << endl ;
    	for(int i = 0; i < rows; i++){
    		for(int j = 0; j < cols; j++){
    			
    			cout<<data[i][j]<<"\t\t";
    		}
    		cout<<endl;
    	}	
    	
    	cout<<endl<<endl;
    } // end of showElements function
    
    void PercentageBiden(int data[][5] , int state){
    	
    	float Bidenvotes = 0.0, totalvotes = 0.0 , percentBiden = 0.0 ;
    	
    	totalvotes = data[state][4];
    	Bidenvotes = data[state][1];
    	percentBiden = (Bidenvotes/totalvotes)*100 ;
    	cout << "Percentage of Jo Biden votes is: " << percentBiden << endl<< endl ;
    	
    } // end of PercentageBiden function
    
    void PercentageTrump(int data[][5] , int state){
    	
    	float Trumpvotes = 0.0, totalvotes = 0.0 , percentTrump = 0.0 ;
    	
    	totalvotes = data[state][4];
    	Trumpvotes = data[state][2];
    	percentTrump = (Trumpvotes/totalvotes)*100 ;
    	cout << "Percentage of Donald Trump votes is: " << percentTrump << endl<< endl ;
    	
    } // end of PercentageTrump function
    
    
    void PercentageJor(int data[][5] , int state){
    	
    	float Jorvotes = 0.0, totalvotes = 0.0 , percentJor = 0.0 ;
    	
    	totalvotes = data[state][4];
    	Jorvotes = data[state][3];
    	percentJor = (Jorvotes/totalvotes)*100 ;
    	cout << "Percentage of Jo Jorgensen votes is: " << percentJor << endl<< endl ;
    	
    } // end of PercentageJor function
    
    main(){
    		
    	int data[rows][cols] = { {1, 5284453, 5658847, 70046, 11013346 } , {2, 2465781, 2455428, 61894, 4983103} , {3, 2790648, 2644525, 60287, 5495460} } ; 
    	
    	showElements(data) ;
    	
    	int choice = 0;
    	do{
    		choice  = selectOption();
    		if(choice != 3){
    		PercentageBiden(data, choice);	
    		PercentageTrump(data, choice);
    		PercentageJor(data, choice);
    		}
     	}while(choice != 3);  // end of do-while loop
     	
     	system("pause");
     	
    } // end of main function
    
    
    
    
    
    
    
  • Cyberian's Gold

    @asma-zahid said in CS201 Assignment 2 Solution and Discussion:

    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
    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:
    Press 1 for Florida.
    Press 2 for Georgia.
    Press 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.

    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.

    #include <iostream>
    #include <time.h>
    #include <stdlib.h>
    using namespace std;
    
    const int rows = 3; 
    const int cols = 5;
    
    int selectOption(){
    	int choice = 0;	
        cout << "Press the state code to calculate percentage of Trum, Biden and Jorgensen votes\n\n" ;
    	
    	cout<<"Press 1 for Florida.\n";
    	cout<<"Press 2 for Georgia.  \n";
    	cout<<"Press 3 for Michigan.\n";
    	cout<<"Press 4 To Exit\n";
    	
    	
    	cout<<"\nPlease select an option, use numbers from 1 to 4: ";
    	
    	do {
    		cin>>choice;
    		if(choice >= 0 && choice <= 4){
    			break;
    		}
    		else {
    			cout<<"\nChoice should be between 1 and 4\n";
    			cout<<"Invalid choice, please select again: ";
    		}
    	} while(true);
    	cout<<"___________________________________________________\n";
    	return choice -1;	
    } // end selectOption function
    
    
    
    void showElements(int data[][5]){
        cout << "Source Data:" << endl << endl ;
    	cout << "States" "\t"<< "\t""\Biden Votes" << "\t" "\Trump Votes" << "\t""\Jorgensen Votes" << "\t" "\Total Votes" << endl << endl ;
    	for(int i = 0; i < rows; i++){
    		for(int j = 0; j < cols; j++){
    			
    			cout<<data[i][j]<<"\t\t";
    		}
    		cout<<endl;
    	}	
    	
    	cout<<endl<<endl;
    } // end of showElements function
    
    void PercentageBiden(int data[][5] , int state){
    	
    	float Bidenvotes = 0.0, totalvotes = 0.0 , percentBiden = 0.0 ;
    	
    	totalvotes = data[state][4];
    	Bidenvotes = data[state][1];
    	percentBiden = (Bidenvotes/totalvotes)*100 ;
    	cout << "Percentage of Jo Biden votes is: " << percentBiden << endl<< endl ;
    	
    } // end of PercentageBiden function
    
    void PercentageTrump(int data[][5] , int state){
    	
    	float Trumpvotes = 0.0, totalvotes = 0.0 , percentTrump = 0.0 ;
    	
    	totalvotes = data[state][4];
    	Trumpvotes = data[state][2];
    	percentTrump = (Trumpvotes/totalvotes)*100 ;
    	cout << "Percentage of Donald Trump votes is: " << percentTrump << endl<< endl ;
    	
    } // end of PercentageTrump function
    
    
    void PercentageJor(int data[][5] , int state){
    	
    	float Jorvotes = 0.0, totalvotes = 0.0 , percentJor = 0.0 ;
    	
    	totalvotes = data[state][4];
    	Jorvotes = data[state][3];
    	percentJor = (Jorvotes/totalvotes)*100 ;
    	cout << "Percentage of Jo Jorgensen votes is: " << percentJor << endl<< endl ;
    	
    } // end of PercentageJor function
    
    main(){
    		
    	int data[rows][cols] = { {1, 5284453, 5658847, 70046, 11013346 } , {2, 2465781, 2455428, 61894, 4983103} , {3, 2790648, 2644525, 60287, 5495460} } ; 
    	
    	showElements(data) ;
    	
    	int choice = 0;
    	do{
    		choice  = selectOption();
    		if(choice != 3){
    		PercentageBiden(data, choice);	
    		PercentageTrump(data, choice);
    		PercentageJor(data, choice);
    		}
     	}while(choice != 3);  // end of do-while loop
     	
     	system("pause");
     	
    } // end of main function
    
    
    
    
    
    
    
  • Cyberian's Gold

    #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++)
    			cout<<vote[b][c]<<"\t\t";
    			cout<<endl;
    		}
    	}
    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--------------------------------------------";
    }
    
    

50% Off on Your FEE Join US!

Quiz 100% Result If you want to know how you can join us and get 50% Discout on your FEE ask Cyberian in Chat Room! Quiz 100% Result Quiz 100% Result
| |