Solved

How do you fix this ? 1 error

Posted on 2006-10-26
1
228 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 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