writing two easy java programs

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadlines.


Order a Similar Paper Order a Different Paper

Exercise 1

Part 1

Create a class SavingsAccount. Use a static class variable to store the annualInterestRate for each of the savers. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit. Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the balance by annualInterestRate divided by 12; this interest should be added to savingsBalance. Provide a static method modifyInterestRate that sets the annualInterestRate to a new value. Write a driver program to test the class SavingsAccount. Instantiate two different savingsAccount objects, saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to 4%, then calculate the monthly interest and print the new balances for each of the savers. Then set the annualInterestRate to 5% and calculate the next months interest and print the new balances for each of the savers.

Part 2

Write another class SpecialSavings that extends SavingsAccount to pay interest of 10% on accounts that have balances that exceed 10K. Also provided methods to deposit and take money out of savings account. Write a driver program to test the class SpecialSavings. Instantiate two different savingsAccount objects, saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Make a few deposits and withdrawals and show balance and interest earned for each account.

Some Tips for helping you with Lab 4:

For Lab 4 part 1 –

Pl. follow the instructions in the assignment and write the class definition. A driver program is the code you would write in main() to exercise the code of class definition.

You should declare private variable in your class definition. You should also write protected methods to set and get the value of private variables.

For Exercise 1 part 2 –

You need to write deposit and withdrawal methods. Should you put this in parent class or child class? Try to answer this question so that you have most reusability in your class definition.

In this part – you have to learn how polymorphism works.

You will have accounts whose balance might be above or below 10K. By using methods in both classes try to change the interest earned to 10% if balance is above 10K or 4% if the interest is lower.

Exercise 2

Design a Ship, CargoShip and CruiseShip class being mindful of behavior of each. Demonstrate the classes in a program that has a Ship array. Assign various Ships, CruiseShip and CargoShip to the array elements.

CargoShip and CruiseShip are a child of Ship class.

Pl. submit a class diagram for each exercise, along with code and test runs.

Rubric

Rubric of Exercise 1, Exercise 2

Rubric of Exercise 1, Exercise 2

CriteriaRatingsPts

This criterion is linked to a Learning OutcomeDescription of criterionNo errors, program always works correctly and meets the specification(s).

2.0 pts

Full Marks

0.0 pts

No Marks

2.0 pts

This criterion is linked to a Learning OutcomeCode could be reused as a whole or each routine could be reused.

2.0 pts

Full Marks

0.0 pts

No Marks

2.0 pts

This criterion is linked to a Learning OutcomeConcepts of Inheritance and Polymorphism are applied.

7.0 pts

Full Marks

0.0 pts

No Marks

7.0 pts

This criterion is linked to a Learning OutcomeJava coding conventions are followed.

1.0 pts

Full Marks

0.0 pts

No Marks

1.0 pts

This criterion is linked to a Learning OutcomeCode Readability (as suggested in class).

1.0 pts

Full Marks

0.0 pts

No Marks

1.0 pts

This criterion is linked to a Learning OutcomeAdequately tested (unique test cases, covering boundary conditions).

1.0 pts

Full Marks

0.0 pts

No Marks

1.0 pts

This criterion is linked to a Learning OutcomeClass diagram is provided (UML usage is not required).

1.0 pts

Full Marks

0.0 pts

No Marks

1.0 pts

Total Points: 15.0

"Is this question part of your assignment? We can help"

ORDER NOW
Writerbay.net

Do you need help with this or a different assignment? We offer CONFIDENTIAL, ORIGINAL (Turnitin/LopesWrite/SafeAssign checks), and PRIVATE services using latest (within 5 years) peer-reviewed articles. Kindly click on ORDER NOW to receive an A++ paper from our masters- and PhD writers.

Get a 15% discount on your order using the following coupon code SAVE15


Order a Similar Paper Order a Different Paper