Solved

How do you fix this ? 1 error

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

772 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