Illegal Start of Expression

creating a prog to calculate multiple loan amorts

Page 1 of 1

7 Replies - 793 Views - Last Post: 09 September 2009 - 06:50 PM Rate Topic: -----

#1 ss_hat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 01-March 09

Illegal Start of Expression

Posted 09 September 2009 - 06:17 PM

 

import javax.swing.*; //gives access to all of the popup box styles


public class loanCompare
{
public static void main (String [] args)

{
Int AmountOfLoans = Integer.parse.Int(JOptionPane.showInputDialog("How many loans would you like to compare?")); / /number of loans to compare, shows question box, converts string to integer
String[] LoanNames = new String[AmountOfLoans];
double[] InterestArray = new double[AmountOfLoans];
double[] InitialPrincipal = new double[AmountOfLoans];
double MountlyPaymentAmount =  Double.parse.Double(JOptionPane.showInputDialog("How much can you pay per month?")); / / loan amountMonthlyPaymentAmount

for ( x=1; x<=AmountOfLoans; x++)
{
LoanNames [ x-1] = JOptionPane.showInputDialog("Name loan " x " eg type of car, house");
InterestArray [x-1] = Double.parse.Double(JOptionPane.showInputDialog("What is the intrest rate?(what percent)")) *.01; / / loan apr in array
InitialPrincipal [x-1]  =  Double.parse.Double(JOptionPane.showInputDialog("How much is the loan for?")); / / loan amount in array

}
}
}


I keep getting illegal start of expression on this line

Int AmountOfLoans = Integer.parse.Int(JOptionPane.showInputDialog("How many loans would you like to compare?")); / /number of loans to compare, shows question box, converts string to integer



This is my first java program I've ever written and I can't figure out why I'm getting this error? The intent of that line is to convert the string into an integer to use in the for loop (which I've yet to write) that will tell the program to terminate once the amount of loans the user wants to compare have been entered.

Is This A Good Question/Topic? 0
  • +

Replies To: Illegal Start of Expression

#2 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Illegal Start of Expression

Posted 09 September 2009 - 06:19 PM

Remove the period that seperates parse and Int

AmountOfLoans = Integer.parseInt(JOptionPane.showInputDialog("How many loans would you like to compare?"));


Yay for my 1000th Post!! :D
Was This Post Helpful? 0
  • +
  • -

#3 ss_hat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 01-March 09

Re: Illegal Start of Expression

Posted 09 September 2009 - 06:24 PM

View PostFuzzyness, on 9 Sep, 2009 - 05:19 PM, said:

Remove the period that seperates parse and Int

AmountOfLoans = Integer.parseInt(JOptionPane.showInputDialog("How many loans would you like to compare?"));


Yay for my 1000th Post!! :D

Just did that, no dice... :( Same exact error.
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is online

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,910
  • Joined: 06-March 08

Re: Illegal Start of Expression

Posted 09 September 2009 - 06:32 PM

View PostFuzzyness, on 9 Sep, 2009 - 05:19 PM, said:

Remove the period that seperates parse and Int

AmountOfLoans = Integer.parseInt(JOptionPane.showInputDialog("How many loans would you like to compare?"));


Yay for my 1000th Post!! :D

And with 147 thanks this is almost a 15% ratio nummberOfPosts/numberOfThanks
Probably the highest in this forum

Good show :^:
Was This Post Helpful? 0
  • +
  • -

#5 ss_hat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 01-March 09

Re: Illegal Start of Expression

Posted 09 September 2009 - 06:38 PM

View Postpbl, on 9 Sep, 2009 - 05:32 PM, said:

View PostFuzzyness, on 9 Sep, 2009 - 05:19 PM, said:

Remove the period that seperates parse and Int

AmountOfLoans = Integer.parseInt(JOptionPane.showInputDialog("How many loans would you like to compare?"));


Yay for my 1000th Post!! :D

And with 147 thanks this is almost a 15% ratio nummberOfPosts/numberOfThanks
Probably the highest in this forum

Good show :^:



What was the point of this post? I'm stuck like glue w/the assignment due tomorrow and you're posting nonsense.
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is online

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,910
  • Joined: 06-March 08

Re: Illegal Start of Expression

Posted 09 September 2009 - 06:42 PM

View Postss_hat, on 9 Sep, 2009 - 05:38 PM, said:

What was the point of this post? I'm stuck like glue w/the assignment due tomorrow and you're posting nonsense.

Fuzzy told you

Int AmountOfLoans = Integer.parse.Int(JOptionPane.showInputDialog

should be

int AmountOfLoans = Integer.parseInt(JOptionPane.showInputDialog
Was This Post Helpful? 0
  • +
  • -

#7 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Illegal Start of Expression

Posted 09 September 2009 - 06:43 PM

Be nice or you wont get help, and be respectful. change the Capital Int to lower case

Int AmountOfLoans = Integer.parse.Int(JOptionPane.showInputDialog("How many loans would you like to compare?"));

you are saying the Int class when you want int type
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is online

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,910
  • Joined: 06-March 08

Re: Illegal Start of Expression

Posted 09 September 2009 - 06:50 PM

View Postpbl, on 9 Sep, 2009 - 05:42 PM, said:

View Postss_hat, on 9 Sep, 2009 - 05:38 PM, said:

What was the point of this post? I'm stuck like glue w/the assignment due tomorrow and you're posting nonsense.

Fuzzy told you

Int AmountOfLoans = Integer.parse.Int(JOptionPane.showInputDialog

should be

int AmountOfLoans = Integer.parseInt(JOptionPane.showInputDialog

And by the way not a good idea to do all that in one line because if the user click on th e "Cancel" button the String returned will be null and parseInt() will fail so you shoud:

String answer = JOptionPane.showInputDialog.....
int amountOfLoans;
if(answer == null) {
... the user pressed the cancel button
}
else {
amountOfLoans = Integer.parseInt(answer);
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1