[go: up one dir, main page]

0% found this document useful (0 votes)
10 views6 pages

Assjdbx

Uploaded by

harsh.becse
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)
10 views6 pages

Assjdbx

Uploaded by

harsh.becse
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
You are on page 1/ 6

Assignment

Course: PG-DAC August 2024


Module: Java Programming

All questions are compulsory.


Practice for the Lab Exam & Viva.

1. A class called InvoiceItem, which models an item of an invoice, with ID,


description, quantity and unit price, is designed as shown in the following
class diagram. Write the InvoiceItem class.

The expected output is:


InvoiceItem[id=A101,desc=Pen Red, qty=888,unitPrice=0.08]
InvoiceItem[id=A101,desc=Pen Red, qty=999,unitPrice=0.99]
id is: A101
desc is: Pen Red
qty is: 999
unitPrice is: 0.99
The total is: 989.01
2. A class called Account, which models a bank account of a customer, is
designed as shown in the following class diagram. The methods
credit(amount) and debit(amount) add or subtract the given amount to the
balance. The method transferTo(anotherAccount, amount) transfers the
given amount from this Account to the given anotherAccount. Write the
Account class.

The expected output is:


Account[id=A101,name=John, balance=88]
Account[id=A102,name=Kumar, balance=0]
ID: A101
Name: John
Balance: 88
Account[id=A101,name=John, balance=188]
Account[id=A101,name=John, balance=138]
Amount exceeded balance
Account[id=A101,name=John, balance=138]
Account[id=A101,name=John, balance=38]
Account[id=A102,name=Kumar, balance=100]

3. A class called Date, which models a calendar date, is designed as shown in


the following class diagram. Write the Date class.

The expected output is:


01/02/2014
09/12/2099
Month: 12
Day: 9
Year: 2099
03/04/2016

4. A class called Customer, which models a customer in a transaction, is


designed as shown in the class diagram. A class called Invoice, which models
an invoice for a particular customer and composes an instance of Customer
as its instance variable, is also shown. Write the Customer and Invoice
classes.
The expected output is:

John(88)(10%)
John(88)(8%)
id is: 88
name is: John
discount is: 8
Invoice[id=101,customer= John (88)(8%),amount=888.8]
Invoice[id=101,customer= John (88)(8%),amount=999.9]
id is: 101
customer is: John (88)(8%)
amount is: 999.9
customer's id is: 88
customer's name is: John
customer's discount is: 8
amount after discount is: 919.91
5. Superclass Shape and its subclasses Circle, Rectangle and Square

Write a class called Square, as a subclass of Rectangle. Convince yourself that


Square can be modeled as a subclass of Rectangle. Square has no instance
variable, but inherits the instance variables width and length from its
superclass Rectangle.
Provide the appropriate constructors (as shown in the class diagram).
Hint:
public Square(double side)
{
super(side, side); // Call superclass Rectangle(double, double)
}
Override the toString() method to return "A Square with side=xxx, which is a
subclass of yyy", where yyy is the output of the toString() method from the
superclass.
Do you need to override the getArea() and getPerimeter()? Try them out.
Override the setLength() and setWidth() to change both the width and
length, so as to maintain the square geometry.

6. Write a java program for Employee Management System(EMS) to perform


the below operation:

1.) Add New Employee


2.) Display all the Employees Details
3.) Delete a Particular Employee.
4.) Search A Particular Employee.

Employee Details should be:


Employee ID, Name, Age and Designation
Use Proper File Handling & Exception Handling Concepts to store the details
of Employees in Employee.txt file.

You might also like