Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Could anyone please help me with this program? and I did below code, but I may miss something.

  1. #1
    Junior Member
    Join Date
    May 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Could anyone please help me with this program? and I did below code, but I may miss something.

    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 calculateMonthlyInterest to calculate the monthly company 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 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.

    **filename: SavingAccount.java**
    SavingAccount class
    public class SavingsAccount [
    public static double annualInterestRate;
    private double savingsBalance;
    public SavingsAccount() [
    annualInterestRate = 0.0;
    savingsBalance = 0.0;
    ]
    public SavingsAccount(double intRate, double savBal) [
    annualInterestRate = intRate;
    savingsBalance = savBal;
    ]
    public double calculateMonthlyInterest() [
    double intRate = (savingsBalance * annualInterestRate/12);
    savingsBalance = savingsBalance + intRate;
    return intRate;
    ]
    public static void modifyInterestRate(double newInteresRate) [
    annualInterestRate = newInteresRate;
    ]
    public void setSavingsBalance(double newBal) [
    savingsBalance = newBal;
    ]
    public double getSavingsBalance() [
    return savingsBalance;
    ]
    public double getAnnualInterestRate() [
    ** return annualInterestRate;**
    Last edited by ramiry; May 16th, 2020 at 06:20 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Could anyone please help me with this assignment ? and I did below code, but I may miss something.

    Do you have any java programming questions?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Could anyone please help me with this assignment ? and I did below code, but I may miss something.

    Yes I do, it is a Java code please help me where did I miss.

    Regards,
    Rustam
    Last edited by ramiry; May 16th, 2020 at 06:17 AM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Could anyone please help me with this assignment ? and I did below code, but I may miss something.

    where did I miss.
    Why do you think something is missing?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    Code with code tags should look like this:
       int var = val;
       if(var > 2) {
          // do something
       }
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Could anyone please help me with this program? and I did below code, but I may miss something.

    Could you please read the requirments and give me the complete code.

    many thanks!
    Last edited by ramiry; May 16th, 2020 at 06:31 AM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Could anyone please help me with this program? and I did below code, but I may miss something.

    it did not run successfully!
    Please explain.
    If there were error messages, copy the full text of the message and paste it here.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    Please read this about code tags: http://www.java-forums.org/misc.php?do=bbcode#code
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    May 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Could anyone please help me with this program? and I did below code, but I may miss something.

    Sir would you please write the code for given requirements?

    Regards,
    Rustam

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Could anyone please help me with this program? and I did below code, but I may miss something.

    Sorry, we do not do students' assignments here.
    You need to explain what the problem is and post any error messages.

    AND you need to edit your post and wrap the code in code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Help with my code for homework assignment, I don't know how to fix it!
    By maxman190 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 19th, 2013, 03:01 AM
  2. [SOLVED] Troubleshoot Help: Darts Hit or Miss using a (for) loop.
    By achamb in forum Loops & Control Statements
    Replies: 2
    Last Post: October 22nd, 2012, 10:58 PM
  3. Java coding for writing telephone bill calculator program
    By eyeore in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 8th, 2009, 10:06 AM