0% found this document useful (0 votes)
4 views4 pages

Java Assignment 4

The document outlines two Java assignments: an Online Shopping System and a Smart Banking System. The first assignment involves creating classes for products, orders, and payment methods, along with exception handling and bill generation. The second assignment focuses on managing bank accounts and transactions, including account creation, deposits, withdrawals, and account summaries, with appropriate exception handling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Java Assignment 4

The document outlines two Java assignments: an Online Shopping System and a Smart Banking System. The first assignment involves creating classes for products, orders, and payment methods, along with exception handling and bill generation. The second assignment focuses on managing bank accounts and transactions, including account creation, deposits, withdrawals, and account summaries, with appropriate exception handling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Assignment 4

Q1: Online Shopping System


Design a system for an e-commerce platform to manage products, orders, and payments.

1.1 Create a class Product with:

i
ba
●​ productId (int)
●​ productName (String)
●​ price (String input from user)

1.2 Add a method in Product to convert price from String to double using Wrapper class.

um
1.3 Create a class Order with:

●​ customerName (String)
●​ array of Product
M
1.4 Write a method in Order to:

●​ iterate through all products


●​ fetch numeric price
AC

●​ calculate and return total bill

1.5 Overload the total calculation method:

●​ one method → normal total


●​ second method → total after applying discount (%)
-D

1.6 Create a method to generate bill using:

●​ StringBuilder or StringBuffer
●​ Include:
C

○​ customer name
○​ list of products
○​ total amount

1.7 Create an interface Payment with:

●​ pay(double amount)
●​ refund(double amount)
1.8 Create two classes:

●​ UPIPayment
●​ CardPayment

Implement Payment and provide different messages (method overriding).

1.9 In main method:

●​ take user input


●​ create products and order

i
●​ ask user to choose payment type

ba
●​ call appropriate payment method

1.10 Add exception handling for:

●​ invalid price (NumberFormatException)

um
●​ product count ≤ 0
●​ invalid payment option

1.11 Display:
M
●​ formatted bill
●​ final payable amount
●​ payment success message
AC
-D
C
Q2: Smart Banking System
Design a system to manage bank accounts and transactions.

2.1 Create a base class Account with:

●​ accountNumber (int)
●​ accountHolderName (String)
●​ balance (double)

2.2 Create derived classes:

i
ba
●​ SavingsAccount
●​ CurrentAccount

using inheritance.

um
2.3 Override a method displayAccountDetails() in both child classes to show account type (method
overriding).

2.4 Create an interface BankService with:


M
●​ deposit(double amount)
●​ withdraw(double amount)

2.5 Implement BankService in account classes and define logic for deposit and withdrawal.
AC

2.6 Accept balance as String input and convert it into double using Wrapper classes.

2.7 Overload deposit method:

●​ deposit(amount)
●​ deposit(amount, bonus)
-D

2.8 Implement withdrawal method:

●​ subtract amount from balance


C

●​ ensure balance does not go below zero

2.9 Create a method to generate account summary using:

●​ StringBuilder or StringBuffer
●​ Include:
○​ account details
○​ current balance

2.10 Add exception handling for:


●​ invalid numeric input
●​ negative deposit/withdrawal
●​ withdrawal greater than balance

2.11 In main method:

●​ take input
●​ create account object
●​ perform deposit and withdrawal
●​ display updated account summary

i
ba
um
M
AC
-D
C

You might also like