Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Savings Account Class

807603Apr 15 2007 — edited Dec 25 2007
I'm having trouble figuring out a program for Java.
Heres the problem:

Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit. Provide method calculateMontlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12---this interest rate should be added to savingsBalance. Provide a static method modifyInterestRate that sets the annualInterestRate to a new value. Write a program to test class SavingsAccount. Instantiate two 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 both savers. Then set the annualInterestRate to 5%, calculate the next month's interest and print the new balances for both savers.

Here is what I have so far:

import java.util.Scanner;

public class SavingsAccount
{
private static int annualInterestRate = .04;
private static int savingsBalance;
private static int
double saver1 = 2000.00;
double saver2 = 3000.00;



public static void main( String[] args)
{

Scanner input = new Scanner ( System.in );


I know this isn't much, but I'm having trouble implementing the methods and private variables it is asking for.

I've been driving myself crazy trying to figure this out with no luck, so any help would be greatly appreciated.

Thanks, James.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 22 2008
Added on Apr 15 2007
4 comments
498 views