You are on page 1of 2

Page 1 of 2

Assignment 02

OOP Section C (Fall- 2020)

Marks: 10+15=25
-All students of OOP Section C are requested to submit the solution on moodle before/on

21h, December, 2020 (Monday).

-No submission will be accepted after due date. This is individual assignment.

-on front page must mention your full name, registration and section.

TASK 1:

Write a definition of class where the main is following

Int main()

Person q; //calling default constructor

q.showPersonDetails();

Person t(q);

t. showPersonDetails();

Person r(3); //calling parameterized constructor

r.showPersonDetails();

Person y(2,”Muhammad”); // calling parameterized constructor

y.showPersonDetails();

}
Page 2 of 2

Task 2:

Imagine a tollbooth at a bridge car passing by the booth is expected to apply a fifty-cent tool. Mostly
they do, but sometime a car goes by without paying. The tollbooth keeps track of the number of cars
that have gone by and of the total amount of money collected.

Model this tollbooth with a class called tollbooth. The two data items are a type-unsigned int to hold
the total number of cars, and a type double to hold the total amount of money collected. A constructor
initializes both these to 0. A member function called payingcar increments the car total and adds 0.50 to
the cash total. Another function, but nopaycar( ), increments the car total but adds nothing to the cash
total. Finally, a member function called display ( ) displays the two totals.

Include a program to test this class. This program should allow the user to press ‘p’ to count a paying
car and ‘n’ to count a non-paying car. Pressing the ‘e’ key should cause the program to print out the
total cars and total cash and then exit.

You might also like