United International University (UIU)
Dept. of Computer Science & Engineering (CSE)
Summer Trimester: 2024
CT-1
CSI 1116: OOP LAB
Q1. You are simulating an Online Shopping Cart.
Create a class named Product with instance variables name, price, and quantity.
Initialize these attributes using a constructor.
Implement a method getTotalPrice() to calculate the total price for the product.
Take User Input and Perform Calculations in the Main Method:
Create an array of Product objects to hold the products.
Create 5 Product objects with values of your choice.
Add each Product object to the array.
Calculate the total bill by summing the total prices of all products in the array.
Print the total bill to the console.
Q2. Create a class named BankAccount that has the following four attributes.
bankName (String)
accountName (String)
balance (double)
accountNumber (int)
a) Create two constructors:
i. The first constructor is a default constructor that only prints “Welcome to the Bank
Account System”
ii. The second constructor will take three parameters named accountNumber, accountName,
and balance and initialize the instance variables using this reference.
b) Create the following methods:
Deposit(double amount): Add the amount to the balance and print a message
indicating the amount deposited.
Withdraw(double amount): Subtract the amount from the balance if sufficient funds
are available; otherwise, print a message indicating insufficient funds.
DisplayAccountInfo(): Display detailed information about the bank account.
TransferMoney(BankAccount b, double amount): Transfer the given amount to
the BankAccount b given in the parameter, also keep check for insufficient balance and
print a message if insufficient.
c) Create another class named Bank. This class contains the main method of the file.
d) Create two instances of BankAccount objects for two different constructors.
● Perform the following tasks:
1. Deposit money into an account
2. Withdraw money from an account
3. Transfer money from a BankAccount to another
4. Display account information after each operation