3 Replies - 7625 Views - Last Post: 26 January 2006 - 09:23 PM Rate Topic: -----

#1 HelpMe777  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-January 06

Programming an amortization table

Posted 26 January 2006 - 07:23 PM

I have know idea where to start can anyone lead me in a direction
here is my assignment

Program #1

Purpose: Demonstrate the ability to create and execute a JAVA program using moderately
complex control structures.

Assignment: Write a program that creates a loan amortization table. The user of the
program will supply values for Initial Loan Principal, Annual Percentage
Rate and Monthly Payment. The program should print out the appropriate
amortization table including the number of Monthly Payments and the Total
Interest paid for the life of the loan. The program should allow multiple
runs (up to 4 different versions) of the table process and should allow the
user to compare runs in a tabular format.

Is This A Good Question/Topic? 0
  • +

Replies To: Programming an amortization table

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1865
  • View blog
  • Posts: 20,278
  • Joined: 17-March 01

Re: Programming an amortization table

Posted 26 January 2006 - 07:33 PM

Hi HelpMe777, welcome to dream.in.code. Our experts will be happy to help you if you can show what you've done so far. Can you please paste what code you've done or what you're struggling with and we will help guide you.

Best of luck with your assignment!
Was This Post Helpful? 0
  • +
  • -

#3 HelpMe777  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-January 06

Re: Programming an amortization table

Posted 26 January 2006 - 07:46 PM

import javax.swing.JOptionPane;

public class homework1 {

 public static void main(String[] args) { 
 //final double TOTAL_NUMBERS =5;
 
 //double[] principal = new double [NUMBER_PRINCIPALS];
 
 System.out.println("Payment #   Principal   Payment      APR   MPR   Interest Payment");
 
 for(int j =1; j< 5; j++) {
  String numstring = JOptionPane.showInputDialog(null, "Enter Principal:",
  "Principal Input", JOptionPane.QUESTION_MESSAGE);
  
 }
 
 JOptionPane.showMessageDialog(null, output, "Principal Input", JOptionPane.INFORMATION_MESSAGE);
 
 
 }
}


This is all i have i am unsure on how to ask a user to enter a value and how to print that value in the ouput this is my first concern

This post has been edited by skyhawk133: 26 January 2006 - 08:08 PM

Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Programming an amortization table

Posted 26 January 2006 - 09:23 PM

Well, you are already asking the user for input, and you are displaying it in a dialog box...it may not be as evident as you like because you are prompting for input in a loop. See the slightly modified code below:
import javax.swing.JOptionPane;

public class homework1 {

public static void main(String[] args) {
double output = 0.0;
System.out.println("Payment #   Principal   Payment      APR   MPR   Interest Payment");


 String numstring = JOptionPane.showInputDialog(null, "Enter Principal:",
 "Principal Input", JOptionPane.QUESTION_MESSAGE);
 

JOptionPane.showMessageDialog(null, numstring, "Principal Input", JOptionPane.INFORMATION_MESSAGE);


}
}


If you run that code, you will see that an input box prompts the user to enter the principal with the line of code here:
 String numstring = JOptionPane.showInputDialog(null, "Enter Principal:",
 "Principal Input", JOptionPane.QUESTION_MESSAGE);


That line of code declares a string (or text) variable named numstring, and places the value entered by the user into that variable. If you wish to perform mathematical operations on it, you will have to convert it to one of the numerical variable types.

You are then displaying that message in another dialog box here:
JOptionPane.showMessageDialog(null, numstring, "Principal Input", JOptionPane.INFORMATION_MESSAGE);


That line of code outputs the value of the variable numstring to the dialog box.

Of course, you will have other requirements to fulfill, but this provides you with a way to interact with the user. Please feel free to ask any further questions you have as you continue to develop your application.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1