Solved

How do you fix this ? 1 error

Posted on 2006-10-26
1
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
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…

735 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