Making a Package class problem...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Making a Package class problem...

  1. #1
    Join Date
    Jul 2004
    Posts
    8

    Making a Package class problem...

    Hi,
    im trying to creat a savingsAccount class and its suppose to have a method that caluculates monthly interest and a modify interest rate method that sets the annual interest rate to a new value.

    heres what it says
    "
    Create class SavingsAccount. Use a static class variable to store the annualInterestRate 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 mehtod calculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance 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 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 each of the savers. Then set the anualInterestRate to 5% and calculate the next month's interest and print the new balances for each of the savers.
    "


    then I have to write a test program to see how it runs:



    I think i need to use set and get methods for the modify annual interest rate method.
    i have this for the savings account class but i know im far off from the finished product, can anyone help me out?


    Code:
    package java.SavingsAccount;
    
    import java.text.DecimalFormat;
    import java.util.Locale;
    
    
    public class SavingsAccount extends Object{
    	
    	private int savingsBalance; //amount saver has on deposit 
    	private static double annualInterestRate;
    	
    	
    	public void setMonthlyInterestRate(double annualInterestRate)
    	{
    		setMIR(annualInterestRate);
    	}
    	
    
    
    	public static double getModifyInterestRate()
    	{
    		return annualInterestRate;
    	}
    	
    	
    	
    			public int calculateMonthlyInterest(savingsBalance)
    			{
    				savingsBalance= (savingsBalance * annualInterestRate)/ 12;
    			}
    			
    }

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    extensively covered by dlorde, on codeguru
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center