Object Oriented Programming Assignment 3
Object Oriented Programming Assignment 3
ISLAMABAD CAMPUS
CS217 Object Oriented Programming- Fall 2020
ASSIGNMENT- 3
Section (A, B, C, D, and F)
Due Date: Sunday 15th November 2020 at 11:59 pm on Google Classroom
Instructions:
1. Assignments are to be done individually. You must complete this assignment by yourself. You cannot
work with anyone else in the class or with someone outside of the class. The code you write must be your
own and you must understand each part of coding. You are encouraged to seek help from the instructors
through email, on google classroom or individually visiting their respective offices.
2. The AIM of this assignment is to practice with Classes and Structures in C++.
3. No late assignments will be accepted.
4. Displayed output should be well mannered and well presented. Use appropriate comments and
indentation in your source code.
5. Plagiarism:
Plagiarism of any kind (copying from others and copying from internet, etc.,) is not allowed. If found
plagiarized, you will be awarded zero marks in the assignment. Repeating such an act can lead to strict
disciplinary actions and failure in course.
Submission Guidelines:
We will be using auto-grading tools, so failure to submit according to the following format would
result in zero marks in the relevant evaluation instrument:
i) For each question in your assignment, make a separate .cpp file e.g. for question 1, make q1.cpp
and so on. Each file that you submit must contain your name, student-id, and assignment # on top
of the file in the comments.
ii) Combine all your work in one folder. The folder must contain only .cpp files (no binaries, no
exe files etc.,).
iii) Run and test your program on a lab machine before submission.
iv) Rename the folder as ROLL-NUM_SECTION (e.g. 19i-0001_B) and compress the folder as a
zip file. (e.g. 19i-0001_B.zip).
v) Submit the .zip file on Google Classroom within the deadline.
vi) Submission other than Google Classroom (e.g. email etc.) will not be accepted.
vii) The student is solely responsible to check the final zip files for issues like corrupt file, virus in
the file, mistakenly exe sent. If we cannot download the file from Google classroom due to any
reason, it will lead to zero marks in the assignment.
Question 1:
Implement a structure Employee. An employee has a name (a char *) and a salary (a double). Write a default
constructor, a constructor with two parameters (name and salary), and methods char* getName()
double getSalary() to return the name and salary.
Write a small global function TestEmployee() to test your structure.
Question 2:
Implement a structure Car with the following properties. A car has a certain fuel efficiency (measured in miles
per gallon or liters per km pick one) of type float and a certain amount of fuel in the gas tank of type float.
The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a method drive (float) that
simulates driving the car for a certain distance, reducing the fuel level in the gas tank, and methods
0.0
20.0
16.551724137931036
Question 3:
Implement a structure Circle (think of its data members) that has methods
float getArea() and
float getCircumference()
In the constructor, supply the radius of the circle.
Please specify the radius of your circle: 1.0
Circle created.
Area: 3.141592653589793
Circumference: 6.283185307179586
Good-bye!
Question 4:
Private Members
A data member FlightNumber of type integer
A data member Destination of type char*
A data member Distance of type float
A data member Fuel of type float
A member function void calFuel() to calculate the value of Fuel as per the following criteria and set its
corresponding data member
Distance Fuel
<=1000 500
more than 1000 and <=2000 1100
more than 2000 2200
Public Members
A function void feedInfo() to allow user to enter values for Flight Number, Destination, Distance & call
function void calFuel() to calculate the quantity of Fuel
A function void showInfo() to allow user to view the content of all the data members
A function float getFuel() that returns the current fuel value.
Question 5:
Implement a class Employee2. An employee has a name (a char *) , HourlyWage (float) , WorkedHours(float)
and ExtraHours(float).
Write a function
float wageCalculator()
that reads in the name and hourly wage of an employee. Then ask how many hours the employee worked
in the past week. Be sure to accept fractional hours. Compute the pay. Any overtime work (over 40 hours
per week) is paid at 150 percent of the regular wage. Print a paycheck for the employee.
Question 6:
Question 7:
Implement a class Account. An account has data member:
a balance(float),
Question 8
Create an instance of the above structure in function named studentDemo void studentDemo() and
demonstrate use of all member function of the structure.
Question 9:
Write the definition for a class called Rectangle that has floating-point data members length and width. The
class has the following member functions:
Question 10:
Implementation of Array Class Your goal is to implement a generic “Array” class. Your implemented class
must fully provide the definitions of following class (interface) functions given in the code snippets below: