Solved

How do you fix this ? 1 error

Posted on 2006-10-26
1
227 Views
Last Modified: 2010-04-16

Showing 1 error so far.
How do you fix this little code? Thanks

import java.text.DecimalFormat;
import javax.swing.JOptionPane;

public class MortgageCalculatorServiceRequest4///Name of my File and Class
{
public static void main(String[] args)
{
double loanAmount;//Declaring my Variables
double loanInterest;//Declaring my Variables
double monthlyPayment;//Declaring my Variables
double interestRate;
int loanTerm;
String totalLoan, interestLoan, termLoan;
DecimalFormat decimalPlaces=new DecimalFormat("0.00"); //Format decimal point for proper display

totalLoan=JOptionPane.showInputDialog(null, "Enter the Term of the Loan: ");
loanAmount = Double.parseDouble(totalLoan);

interestLoan=JOptionPane.showInputDialog(null, "Enter the Interest Rate of the Loan in decimal Form: ");
loanInterest = Double.parseDouble(interestLoan)/12;

termLoan=JOptionPane.showInputDialog(null, "Enter the Term of the Loan: ");
loanTerm = Integer.parseInt(termLoan)*12;

// calculations
monthlyPayment = (loanAmount * loanInterest) / (1 - Math.pow(1 + loanInterest, -loanTerm));//Formula for Monthly Payments

JOptionPane.showMessageDialog(null,"Your Monthly Payments Are" + decimalPlaces.format(monthlyPayment),JOptionPane.PLAIN_MESSAGE );
System.exit(0);
}}
0
Comment
Question by:charliebaby
1 Comment
 
LVL 1

Accepted Solution

by:
Harteex earned 500 total points
ID: 17814053
JOptionPane.showMessageDialog wants to have a title too.
Add a title before JOptionPane.PLAIN_MESSAGE.

Like this:
JOptionPane.showMessageDialog(null,"Your Monthly Payments Are" + decimalPlaces.format(monthlyPayment),"Your title",JOptionPane.PLAIN_MESSAGE );


Harteex
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 65
Fibonacci challenge 11 84
VB6 Compile Compatibility Issue 4 38
Turning python script into an applet 12 43
A short article about a problem I had getting the GPS LocationListener working.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now