Private auction for Jtaborda (from Kanth90) on 10/20/2008 9:14:33 PM(repost)
$15-20 USD
Dibatalkan
Dibuat lebih dari 15 tahun yang lalu
$15-20 USD
Dibayar ketika dikirim
Small Java Program for school.
## Deliverables
Q 1: This problem? is related to inheritance. You need to define three classes named **Accounts**, **Saving_Account**, and **Bonus_Saver_Account**.
?
Following are the important points of the problem / assignment.
?
(a)? ? ? class **Saving_Account** will have the following instance variables.
**? **
private int account? ? ? ? ? ? ? ? ? ? //? this field will represent the account number
private double balance? //? this field will represent the balance of the account
private double rate;? ? ? ? ? ? ? ? ? ? // this field will represent the interest rate
?
(b)? ? class **Bonus_Saver_Account** is derived from class **Saving_Account.**
?
(c)? ? ? Interest rate will be applied to the balance according to the formula as balance*rate. This will give new balance after applying the interest rate.
?
(d)? ? You will develop following methods as part of your **Saving_Account** class.
?
A constructor
A method for deposit named as deposit ( )
A method for withdrawl named as withdrawl ( )
A method for adding interest named as add_interest ( )
?
(e)? ? ? the derived class **Bonus_Saver_Account** will have following two instance variables :
?
PENALTY and it will have value (double 25.00 ) which cannot be changed in the program.
BONUS_RATE, it will have value (double 0.03) and cannot be changed.
?
? ? ? ? ? Following methods will be part of the derived class:
? ? ? ? ? A constructor.
? ? ? ? ? A withdrawl method (*call super class withdrawl method* passing suitable parameters.)
? ? ? ? ? An add_interest method (this method will add additional BONUS_RATE to the?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? existing interest rate. *Call super class Add_interest ( )*
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? passing BONUS_RATE as parameter)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?
(f)? ? ? class **Accounts** will contain the main ( ) method. You will use the following data for creating the objects of the class **Saving_Account** and **Bonus_Saver_Account** :
?
**for Saving_Account object :**? account number = 4321
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? balance = 8921.39
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? interest rate = 0.02
?
**for Bonus_Saver_Account object:** account number = 6543
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? balance = 1225.00
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? interest_rate = 0.02
In addition to the creation of two objects with above data, you will call the following methods for each of the above objects:
?
**Add_interest ( )** ??" pass BONUS_RATE parameter
?
**deposit ( ) method** with parameter value 390.23 for Saving_Account object and parameter value 250.45 for Bonus_Saver _Account object.
**? **
**Withdrawl ( ) method** with parameter value 432.34 for Saving_Account object and parameter value 875.95 for Bonus_Saver _Account object.
### ?
C:\myjava>java? Accounts
?
? Interest added to account # : 4321
? New balance:9099.817799999999
======================================
?
? Interest added to account # : 6543
? New balance:1286.25
======================================
?
? Deposit into account: 4321
? Amount:390.23
? New balance: 9490.047799999998
=========================================
?
? Deposit into account: 6543
? Amount:250.45
? New balance: 1536.7
=========================================
?
? Withdrawl from account #: 4321
? Amount:432.34
? New balance: 9057.707799999998
=========================================
? Penalty Incurred: 25.0
?
? Withdrawl from account #: 6543
? Amount:900.95
? New balance: 635.75
=========================================
#### C:\myjava>