Object Oriented Programming Assignment 1
Object Oriented Programming Assignment 1
ISLAMABAD CAMPUS
CS217 Object Oriented Programming- Fall 2020
ASSIGNMENT- 1
Section (A, B, C, D, and F)
Due Date: Wednesday 21st October 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 Pointers, Dynamic Memory Allocation (DMA) 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.
6. 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:
Dear students we will be using auto-grading tools, so failure to submit according to the below
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.
Q2. Write a C++ program using a dynamic array (or arrays) to assign passengers seats in a Bus
and your program will ask the user how many rows the Bus has and will handle that many rows
(Assume the Bus does not always have the same rows). (5 points)
1ABCD
2ABCD
3ABCD
4ABCD
5ABCD
6ABCD
7ABCD
8ABCD
9ABCD
10 A B C D
The program should display the seat pattern, with an X marking the seats
already assigned. For example, after seats 1A, 2B, and 4C are taken, the
display should look like this: (5 points)
1XBCD
2AXCD
3ABCD
4ABXD
5ABCD
6ABCD
7ABCD
8ABCD
9ABCD
10 A B C D
After displaying the seats available, the program prompts for the seat
desired, the user types in a seat, and then the display of available seats is
updated. This continues until all seats are filled or until the user signals
that the program should end. If the user types in a seat that is already
assigned, the program should say that the seat is occupied and ask for
another choice. (10 points)
Q3. Write a C++ program using dynamic arrays that allows the user to enter the last names of
the candidates in a local election and the number of votes received by each candidate. The
program must ask the user for the number of candidates and then create the appropriate arrays
to hold the data. The program should then output each candidate’s name, the number of votes
received, and the percentage of the total votes received by the candidate. Your program
should also output the winner of the election. (20 points)
Q4. Write a C++ program that outputs a histogram of student Marks for a Mid-term-1
Examination. The program should input each student’s Marks as an integer and store the
Marks in a dynamic array. Marks should be entered until the user enters -1 for marks. The
program should then scan through the Dynamic array and compute the histogram. In
computing the histogram, the minimum value of a marks is 0 but your program should
determine the maximum value entered by the user. Then use a dynamic array to store and
output the histogram. (20 points)
For example,
if the input is:
80
60
80
70
60
50
50
50
-1
Then the output should be:
The frequency of 80's: 2
The frequency of 70's: 1
The frequency of 60's: 2
The frequency of 50's: 3
Q5. Write a C++ program, which will prompt the user for entering an amount in Pakistani
currency and convert the rupees amount to the Chinese Yuan currency. You must use only
one pointer. Your program must print the Pakistani rupees and the Chinese Yuan converted
amount. Your program should allow the user to repeat the program using different Rupees
values until the user decides to quit the program. (20 points)