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 12 of 12

Thread: Calc_Bank_Interest

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Calc_Bank_Interest

    The requirements of the take home part of the java1 FINAL are as follow:

    (1) Design the BANK ACCOUNT balance and interest calculation project (p252, Q10) using class, constructors, and methods approach as of the principle described in Chapter 6.
    (2) You have to design at least 4 methods and three constructors in the class.
    (3) Design a demo program with loop for various interest rates I/P from a user of your program.
    (4) Use GUI style statement for the I/O (input and output) operation.
    (5) This project of the final is 30 points. If your name is not in the program source, no points is given.
    (6) Your program source file name (java class file name) should be in this format: W0x_XY_FINAL.java
    W0x is the course section name: W02, or W03, XY is your first name and last name initial.
    If your program source file name not in this format, there will be 20 points deduction.
    (7) If there are syntax error (compilation error), there will be no points.
    (8) If the program is not stored in java format source file extension, no points.
    (9) If the program source file is not attached as a java file extension, no points.
    (10) You may use the sample solution of the project emailed to you before as a base.

    (11) The subject line of your email for the FINAL must write in this format:

    Your full name, W0x_XY_FINAL.java (as of item 6 format).

    NOTE: If the subject line is missing or not in this format, 20 points deduction.
    Attached Files Attached Files

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Calc_Bank_Interest

    What have you tried? Post your code and your questions.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calc_Bank_Interest

    Hello Norm I am having an issue modifying the current program and creating four methods and three constructors within the class. JOption is recommended to issue input and output dialogs. The current code to modify is:
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package calc_bank_interest;

    /**
    *
    * @author
    */
    import javax.swing.JOptionPane;
    public class Calc_Bank_Interest
    {
    public static void main (String[] args)
    {
    double b, i; // balance (original deposit), interest rate
    String s1 = "Course: CS-125 prog 1 with java 1, FALL 2013";
    String s2 = "\nSample program by Prof, for HW chapter 4";
    String s3 = "\n\nCalculate interest gain of a deposit with interest rate";
    String s4 = "With interest rate compounded annually your account balance";
    String s5 = "With interest rate compounded monthly your account balance";
    String s6 = "With interest rate compounded daily your account balance";
    String s7 = " in 10 years will be $";
    String cont; //ask if continue for more calculation

    JOptionPane.showMessageDialog (null, s1 + s2 + s3); //show program purpose

    do
    {
    b = Double.parseDouble (JOptionPane.showInputDialog("Enter deposit amount: "));
    i = Double.parseDouble (JOptionPane.showInputDialog("Enter interest rate: "));

    double bY = b; //balance for interest compounded yearly
    for (int y = 1; y <= 10; y++) //loop thru 10 years (y)
    { bY = bY * ( 1 + i/100 ); }

    double bM = b; //balance for interest compounded monthly
    for (int y = 1; y <= 10; y++) //loop thru 10 years
    {
    for (int m = 1; m <= 12; m++) //loop thru 12 months for each year
    { bM = bM * ( 1 + i/100/12); }
    }

    double bD = b; //balance for interest compounded daily
    for (int y = 1; y <=10; y++) //loop thru 10 years
    {
    for(int d =1; d <= 365; d++) //loop thru 365 days for each year
    { bD = bD * ( 1 + i/100/365); }
    }

    JOptionPane.showMessageDialog (null, "Deposit amount= $" + b + " with interest rate: " + i + "%\n"
    + "\n" + s4 + s7 + String.format("%1.2f", bY) //bal by Yearly interest
    + "\n" + s5 + s7 + String.format("%1.2f", bM) //bal by Monthly interest
    + "\n" + s6 + s7 + String.format("%1.2f", bD)); //bal by Dailly interest

    cont = JOptionPane.showInputDialog ("Continue to calculate of different amount? (Y/N)? ");

    } while(cont.equalsIgnoreCase ("Y"));

    JOptionPane.showMessageDialog ( null, "End of Job"); System.exit(0);

    }
    }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Calc_Bank_Interest

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting. Make sure the statements are properly indented.

    Make a list of what needs to be done and start at the top. What is the first problem?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calc_Bank_Interest

    Create four methods
    Create three constructors
    Use JOption for input and output

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package calc_bank_interest;
     
    /**
     *
     * @author 
     */
    import javax.swing.JOptionPane;
    public class Calc_Bank_Interest
    {
    public static void main (String[] args) 
    {
    double b, i;	 // balance (original deposit), interest rate
    String s1 = "Course: CS-125 prog 1 with java 1, FALL 2013";
    String s2 = "\nSample program by Prof, for HW chapter 4";
    String s3 = "\n\nCalculate interest gain of a deposit with interest rate";
    String s4 = "With interest rate compounded annually your account balance";
    String s5 = "With interest rate compounded monthly your account balance";
    String s6 = "With interest rate compounded daily your account balance";
    String s7 = " in 10 years will be $";
    String cont;	 //ask if continue for more calculation
    JOptionPane.showMessageDialog (null, s1 + s2 + s3);	//show program purpose
    do
    {
    b = Double.parseDouble (JOptionPane.showInputDialog("Enter deposit amount: "));
    i = Double.parseDouble (JOptionPane.showInputDialog("Enter interest rate(%): "));
    double bY = b;	 //balance for interest compounded yearly
    for (int y = 1; y <= 10; y++)	 //loop thru 10 years (y)  
    {	bY = bY * ( 1 + i/100 ); }
    double bM = b;   //balance for interest compounded monthly
    for (int y = 1; y <= 10; y++)	 //loop thru 10 years
    {
    for (int m = 1; m <= 12; m++)	 //loop thru 12 months for each year
    {	bM = bM * ( 1 + i/100/12);	}
    }
    double bD = b;                   //balance for interest compounded daily
    for (int y = 1; y <=10; y++)	 //loop thru 10 years
    {
    for(int d =1; d <= 365; d++)	 //loop thru 365 days for each year
    {	bD = bD * ( 1 + i/100/365);	}
    }
    JOptionPane.showMessageDialog (null, "Deposit amount= $" + b + " with interest rate: " + i + "%\n"
    + "\n" + s4 + s7 + String.format("%1.2f", bY)	//bal by Yearly interest
    + "\n" + s5 + s7 + String.format("%1.2f", bM)	//bal by Monthly interest
    + "\n" + s6 + s7 + String.format("%1.2f", bD));	//bal by Dailly interest
    cont = JOptionPane.showInputDialog ("Continue to calculate of different amount? (Y/N)? ");
    }	while(cont.equalsIgnoreCase ("Y"));
    JOptionPane.showMessageDialog ( null, "End of Job");	System.exit(0);
    }
    }

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Calc_Bank_Interest

    The code has lost all its formatting. Logically nested statements need to be indented. Not all statements should start in the first column.

    What is the first one you want to work on? What problems are you having with it? What have you tried?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calc_Bank_Interest

    I want to work on creating methods first!

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Calc_Bank_Interest

    Which one? What problems are you having with it? What have you tried?
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calc_Bank_Interest

    Creating different methods for daily, monthly and yearly balances with compounded interest.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Calc_Bank_Interest

    Which one is first?
    What arguments are passed to it?
    Do you have the formula needed for the computation?
    What does it return?
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calc_Bank_Interest

    Yearly would be first and I would like the JOptionPane to display output after input with System.out.println( "Your interest at the end of year " + count); and also display output with ("End of Program? "Y/N").

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Calc_Bank_Interest

    Yearly would be first
    What arguments are passed to it?
    Do you have the formula needed for the computation?
    What does it return?

    What have you tried?
    If you don't understand my answer, don't ignore it, ask a question.