Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3243972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:29:45+00:00 2026-05-17T18:29:45+00:00

I’m working on a network application for my class. Basically I have to write

  • 0

I’m working on a network application for my class. Basically I have to write java and jsp to make a site that gives the .jsp output below (which is preceded by a .jsp page that asks for the balance, rate, and period). I’m writing the java for it now and I’m trying to make a html table with the Java class.

The problem I’m having is to make it so that the table is showing the standard deviation of 2 for the rate (rows) and period (columns). Instead of just adding all of the information for all periods and rates. How do I narrow it?

note: I know the code in my table is really not correct at all, I think everything else is OK though

My Code so far:

    package SavingAcct;

    import java.text.*;

    public class savingsAccount {

private double rate;
private double currentBalance;
private int term;

public savingsAccount() {

    this.rate = 0.00;
    this.currentBalance = 0.00;
    this.term = 0;


}

public savingsAccount(double rate, double currentBalance, int term) {

    this.rate = rate;
    this.currentBalance = currentBalance;
    this.term = term;


}

/**
 * @return the term
 */
public int getTerm() {
    return term;
}

/**
 * @param term the term to set
 */
public void setTerm(int term) {
    this.term = term;
}

/**
 * @return the rate
 */
public double getRate() {
    return rate;
}

/**
 * @param rate the rate to set
 */
public void setRate(double rate) {
    this.rate = rate;
}

/**
 * @return the balance
 */
public double getBalance() {

    return currentBalance;
}

/**
 * @param balance the balance to set
 */
public void setBalance(double balance) {
    this.currentBalance = balance;
}

public String doSavingsAccount() {
    String htmlSavingsTable = "";


    NumberFormat cf = NumberFormat.getCurrencyInstance();
    NumberFormat pf = NumberFormat.getPercentInstance();

    //start the html table
    htmlSavingsTable = "<table border='2'>";
    //create a table heading
    htmlSavingsTable += "<tr>";
    htmlSavingsTable += "<td><b>  -  </b></td>";
    htmlSavingsTable += "<td><b>" + (term-2) + "</b></td>";
    htmlSavingsTable += "<td><b>" + (term-1) + "</b></td>";
    htmlSavingsTable += "<td><b>" + term + "</b></td>";
    htmlSavingsTable += "<td><b>" + (term+1) + "</b></td>";
    htmlSavingsTable += "<td><b>" + (term+2) + "</b></td>";
    htmlSavingsTable += "</tr>";

    for (double rate = this.getRate()-2; rate <= getRate()+2;){


        // start html table row for 
        htmlSavingsTable += "<tr>";
        // add rate to row
        htmlSavingsTable += "<td><b>" + pf.format(rate-2) + "</b></td>";
        // add monthly payment to row
        htmlSavingsTable += "<td><b>" + cf.format(getNewBalance())+     "</b></td>";
        // end the row
        htmlSavingsTable += "</tr>";


    }
    // end the table
    htmlSavingsTable += "</table>";

    return htmlSavingsTable;

}

public double getNewBalance() {
    double newBalance;
    newBalance = currentBalance * (Math.pow((1+rate), term));
    return newBalance;
}


    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:29:46+00:00Added an answer on May 17, 2026 at 6:29 pm

    You need to increment rate in your for loop for a start, then need to iterate over each possible term, and pass term and rate to the getNewBalance() function.

    Edit: code

    package acme.savingacct;
    
    import java.text.NumberFormat;
    
    public class SavingsAccount {
        private transient double startingRate;
        private transient double currentBalance;
        private transient int startingTerm;
    
        public SavingsAccount(final double startingRate,
                final double currentBalance, final int startingTerm) {
            this.startingRate = startingRate;
            this.currentBalance = currentBalance;
            this.startingTerm = startingTerm;
        }
    
        public SavingsAccount() {
            this.startingRate = 0.0;
            this.currentBalance = 0.0;
            this.startingTerm = 0;
        }
    
        /**
         * @return the term
         */
        public final int getStartingTerm() {
            return startingTerm;
        }
    
        /**
         * @param term
         *            the term to set
         */
        public void setStartingTerm(final int term) {
            this.startingTerm = term;
        }
    
        /**
         * @return the rate
         */
        public final double getStartingRate() {
            return startingRate;
        }
    
        /**
         * @param rate
         *            the rate to set
         */
        public void setStartingRate(final double rate) {
            this.startingRate = rate;
        }
    
        /**
         * @return the balance
         */
        public final double getBalance() {
            return currentBalance;
        }
    
        /**
         * @param balance
         *            the balance to set
         */
        public void setBalance(final double balance) {
            this.currentBalance = balance;
        }
    
        @Override
        public String toString() {
            final StringBuffer htmlSavingsTable = new StringBuffer(1024);
            final NumberFormat currFmt = NumberFormat.getCurrencyInstance();
            final NumberFormat pctFmt = NumberFormat.getPercentInstance();
    
            // start the html table & create a table heading
            htmlSavingsTable.append("<table border='2'>\n  <tr>\n"
                    + "    <th>  -  </th>\n");
    
            for (int term = getStartingTerm(); term < getStartingTerm() + 5; term++) {
                htmlSavingsTable.append("    <th>" + term + "</th>\n");
            }
    
            htmlSavingsTable.append("  </tr>\n");
    
            for (double rate = getStartingRate(); rate < getStartingRate() + 5.0; rate++) {
                // start html table row for rate & add rate to row
                htmlSavingsTable.append("  <tr>\n    <th>"
                        + pctFmt.format(rate / 100.0) + "</th>\n");
    
                // add monthly payment to row
                for (int term = getStartingTerm(); term < getStartingTerm() + 5; term++) {
                    htmlSavingsTable
                            .append("    <td>"
                                    + currFmt.format(getNewBalance(rate, term))
                                    + "</td>\n");
                }
    
                // end the row
                htmlSavingsTable.append("  </tr>\n");
            }
    
            // end the table
            htmlSavingsTable.append("</table>");
    
            return htmlSavingsTable.toString();
        }
    
        /**
         * @param aRate
         *            the rate
         * @param aTerm
         *            the term
         * @return the calculated balance
         */
        public double getNewBalance(final double aRate, final int aTerm) {
            double newBalance;
            newBalance = currentBalance * (Math.pow((1 + aRate / 100.0), aTerm));
            return newBalance;
        }
    
        /**
         * For testing purpose ..
         * 
         * @param args
         */
        public static void main(final String[] args) {
            final SavingsAccount sacc = new SavingsAccount(5.0, 1000.0, 12);
            System.out.println(sacc);
        }
    
    }
    

    Output:

    alt text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.