INT201 OOP Labsheet 5 2022 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

College of Engineering and Information Technology

INT201 Object Oriented Programming

2nd semester 2022/2023


Lab Sheet#5
EX#1
1. Referring to the Temperature class of Lab Sheet #4, add the following two member
methods:
 Define a method higherTemperatures() that takes an object of type Temperature
as a parameter. The method compares two objects of type Temperature and returns a
copy of the object with the higher temperature.
 Define a method averageTemperature that takes an object of type Temperature
as a parameter. The method should return the average temperature of two objects.

2. Using this updated class, write a driver class (program) that reads the value of the
temperature for two objects and,
a. Print the maximum temperature of the two objects,
b. Print the average temperature of the two objects.

EX#2
1. Define a class Account with the following data members, constructors, and methods:
 Two data members: ownerName of type String, and balance of type double.
 A default constructor.
 A constructor with parameters.
 A set method for the name.
 A set method for the balance.
 A method to print the owner name and balance of an account.
 A method totalBalance() that takes an object of type Account as a parameter and returns
the sum of the total of two objects of type Account.
 Define a method compareAccounts() that one object of type Account as a parameter. The
method should return a copy of the object with the higher balance.

2. You program should then,


a. Print the total balance of two Accounts.
b. Print the name and the balance of the customer with the higher balance.

You might also like