Assignment#01 OOP (Spring 2024)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Continued From Overleaf

UNIVERSITY OF MANAGEMENT AND TECHNOLOGY


School of Systems and Technology
Department of Informatics & Systems
Spring Semester 2024

Instructor’s Name: Umair Ghazanfar Subject: Object Oriented Programming

Subject Code: Assignment #: 1

Total Marks: 50 Assigning Date: 18-04-2024

Due Date & Time: 25-04-2024

Instructions for Candidates


i. Read the instructions carefully.
ii. Write Question number and its part number clearly.
iii. Attempt all questions.

Question # 01 (CLO 1, CLO 2 – 10 marks)


Create a class called 'Matrix' containing constructor that initializes the number of
rows and the number of columns of a new Matrix object. The Matrix class has the
following information:
1 - Number of rows of matrix
2 - Number of columns of matrix
3 - Elements of matrix (You can use 2D vector)

The Matrix class has functions for each of the following:

1 - Get the number of rows


2 - Get the number of columns
3 - Set the elements of the matrix at a given position (i,j)
4 - Adding two matrices.
5 - Multiplying the two matrices

You can assume that the dimensions are correct for the multiplication and addition.

Page 1 of 3
Please turn over
Continued From Overleaf

Question # 02 (CLO 1, CLO 2 – 10 marks)

Create a class called "BankAccount" with the following private members:


"account_number" (string), "account_holder_name" (string), "balance" (double),
and "interest_rate" (double). Implement three constructors for the class: a default
constructor that initializes the account number and account holder name to
"unknown", balance to 0, and interest rate to 0.01; a constructor that takes in an
account number and account holder name and sets the balance and interest rate to
their default values; and a constructor that takes in an account number, account
holder name, balance, and interest rate.

Question # 03 (CLO 1 – 10 marks)


You have been tasked with developing a program that models a football player for
a sports team. Each player has a name, a team name, a position, and a rating. The
program should allow for the creation of new players, as well as the modification of
existing players' information. The program should also be able to calculate the
overall rating of a team based on the ratings of its players.

Question # 04 (CLO 1 – 10 marks)


Define a class BOOK with the following specifications:
Private members of the class BOOK are
BOOK NO integer type
BOOKTITLE 20 characters
PRICE float (price per copy)
TOTAL_COST() A function to calculate the total cost for N number
of copies where N is passed to the function as argument.
Public members of the class BOOK are
INPUT() function to read BOOK_NO. BOOKTITLE, PRICE
PURCHASE() function to ask the user to input the number of copies to
be purchased. It invokes TOTAL_COST() and prints the total cost to be paid
by the user.

Page 2 of 3
Please turn over
Continued From Overleaf

Question # 05 (CLO 1 – 10 marks)

Define a C++ structure for a book, containing the following members: title, author,
ISBN, and number of pages. Write a function that takes an array of book structures
and returns the total number of pages across all books.

Page 3 of 3
Please turn over

You might also like