0% found this document useful (0 votes)
485 views4 pages

Spring 2024 - CS201P - Assignment#2

Uploaded by

ms4535358
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)
485 views4 pages

Spring 2024 - CS201P - Assignment#2

Uploaded by

ms4535358
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/ 4

Assignment No.

2 Total Marks: 20
Semester: Spring 2024 Due Date: Monday,
CS201P – Introduction to Programming(Practical) June 24, 2024.
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 the due date.


o Submitted assignment does not open or file is corrupt.
o Assignment is copied (From the internet/students).
o Assignment is submitted in any file format other than .cpp.

Recommended tool to develop Assignment


- Dev C++

Objectives:
To enable students to understand and practice the concepts of:
 Class
 Object

Assignment Submission Instructions


You must submit only a .cpp file on the assignments interface of CS201P from your LMS account. Assignments
submitted in any other format(image, pdf, doc, docx, etc) will be scaled with zero marks. So, check your
solution file format before submission.

For any query related to the assignment, please contact [email protected].

Assignment

You are required to write a C++ program to find the performance of cricket players after a match. The detailed
requirements of assignment task are given below.
1. Store the information of each player
2. Give a turn to each player and calculate total score and balls played.
3. Display the score of every ball played by the player.
4. Display OUT message if a player is out on a ball.
5. Display total balls played by a Player.
6. Display summary of match (Player Name, Score, Balls Played).
7. Display man of the match (Player name with highest score).

Solution Instructions and Hints


 Create a Player class that has three data members (playerName, totalScore, ballsPlayed).
 Create a string type array in the main function and store players names (names shown in above screenshot).
 Create 11 objects of Player class and store the player name, score and balls played turn by turn as shown in
sample output video (Video is attached with assignment file).
 Use rand( ) function to generate a number between -1 to 6 except 5.
o The value “-1” means the player is OUT.
o 0 to 6 will be used for score on a ball except 5 because 5 is considered a invalid score (unless special
cases which are not covered in our scenario).
o Formula to control the random number in specific range is lower + rand( ) % (upper - lower + 1).
 The title man of the match will be decided on the basis of highest score.
 Sample screenshots are shown below for better understanding of requirements and working of required
program.
 The structure of class that you will create in your program is showing below.

Player
-playerName:string
-totalScore:int
-ballsPlayed:int
+setName(string):void
+getName():string
+setScore(int):void
+getScore():int
+setBalls(int):void
+getBalls():int
Sample Video:
 To open the sample video, double-click on the following file.

Syllabus:
The syllabus for this assignment includes all topics covered from Lab 8 to Lab 11.
Best of luck!

You might also like