0% found this document useful (0 votes)
93 views2 pages

OOP1 Lab - 07 - Fall

1. The document provides instructions for a lab assignment on object oriented programming. Students are asked to continue developing classes from the previous lab and create new classes. 2. Students should create a Calculator class with methods for basic arithmetic operations and check for exceptions. They should also create an Account class to represent bank accounts with methods like deposit, withdraw, and transfer between accounts. 3. Two custom exception classes are to be created - ZeroAsParameterException to handle zero parameters and NegativeResultException to handle negative results from certain operations. Students must follow naming conventions and declare members and methods properly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views2 pages

OOP1 Lab - 07 - Fall

1. The document provides instructions for a lab assignment on object oriented programming. Students are asked to continue developing classes from the previous lab and create new classes. 2. Students should create a Calculator class with methods for basic arithmetic operations and check for exceptions. They should also create an Account class to represent bank accounts with methods like deposit, withdraw, and transfer between accounts. 3. Two custom exception classes are to be created - ZeroAsParameterException to handle zero parameters and NegativeResultException to handle negative results from certain operations. Students must follow naming conventions and declare members and methods properly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Object Oriented Programming 1

Fall 2015-16
Lab Manual: 07

Lab Task:
1. Lab Review, and start with unfinished classes from Lab_06
2. Develop Java classes

Note: Student must follow the name of class, member variables, and functions.
And students should use fully qualified names for these, as well camel notions.
And the syntax alignment has to be as it should be.

1. Lab_06 Classes – Review:

2. Develop Java Classes:

Calculator double x Member variables


Class double y Declare Private
2 Constructor (Empty, valued) Declare public

double add(double x, double y) Declare public


double sub(double x, double y)
double mul(double x, double y)
double div(double x, double y)
ArithmeticException Check arithmetic dependency

IOException Check Input Output Exceptions

Use java.utill.Scanner class to take input from the console.

The program will ask for the choice of operation from the user first. User will input the choice then the
value of the operations will be given.

Account Class String accName Member variables


String acid
int balance declare private

2 Constructor (Empty, valued)

deposit(int amount)
Withdraw(int amount)

transfer(int amount, Account Transfer amount from one


receiver) account to another account

Exception Class ZeroAsParameterException if any of the parameter is 0 (zero)


ZeroAsParameterException throws message “0 cannot be a
Check before withdraw and deposit
parameter” that will be
identifiable during compile
time.

Exception Class NegativeResultException if the result of subtraction or


NegativeResultException throws “Result cannot be addition is negative
negative” that will not be
Check before withdraw and deposit
identifiable during compile
time.

You might also like