Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1804 > unrolled thread
| Started by | "pacvek" <pacvek@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:35 +0000 |
| Last post | 2011-04-27 15:36 +0000 |
| Articles | 18 — 8 participants |
Back to article view | Back to comp.lang.java.gui
'{' expected "pacvek" <pacvek@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "pacvek" <pacvek@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "pacvek" <pacvek@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "pacvek" <pacvek@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "pacvek" <pacvek@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "kaldrenon" <kaldrenon@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Aziz" <aziz@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "JT" <jt@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "pacvek" <pacvek@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
Re: '{' expected "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
| From | "pacvek" <pacvek@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Subject | '{' expected |
| Message-ID | <1181696976.341554.101430@x35g2000prf.googlegroups.com> |
To: comp.lang.java.gui
hi everyone, I'm new to the java world and I'm need of dire help, I
have been given an assignment and for some reason I cannot compile, I
keep getting the same error and even when I add an extra bracket the
error gets greater, here is the program and hopefully someone can help
me out.
import java.text.DecimalFormat;
public class Mortgage Payment Calculator {
//initialize numerical values
public static void main(String[] args)
{
//declared variables
int loanamount = 200000;
double MP;
double Principal=200000;
int[] months= new int[3];
months[0] = 84;
months[1] = 180;
months[2] = 360;
//calculate
double[] interestrate= new double[3];
interestrate[0] = .0535;
interestrate[1] = .0550;
interestrate[2] = .0575;
DecimalFormat twoplaces = new DecimalFormat("0,000.00");
//calculate
System.out.println("\tMortgage Payment Calculator\n");
//looping in progress
for(int counter = 1; counter <=12; counter++);
{
//calculate
PayMonthly = (loantotal * interestRate[i] / (1 - Math.pow(1/(1 +
interestRate[i]),loanlength[i]*12)));
{
//calculate
System.out.println("\tLoan Amount 1 = " + loanamount);
System.out.println("\tYear Term is = " + yearterm[counter]);
System.out.println("\tInterest Rate = " +
interestrate[counter]*100);
System.out.println("\tMonthly Payment is " + twoplaces.format(MP));
}
}
}
}
}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <739dc1a5cd451@uwe> |
| In reply to | #1804 |
To: comp.lang.java.gui
pacvek@aol.com wrote:
>hi everyone, I'm new to the java world ...
An inappropriate time to be taking on GUI'd applications.
>...and I'm need of dire help,
Best help for beginners is available on comp.lang.java.help
>...I
>have been given an assignment and for some reason I cannot compile, I
>keep getting the same error ...
What error? Always copy/paste compile and runtime
error output.
>...and even when I add an extra bracket the
>error gets greater, here is the program and hopefully someone can help
>me out.
>
>import java.text.DecimalFormat;
>
>public class Mortgage Payment Calculator {
D:\MortgagePaymentCalculator.java:3: '{' expected
public class Mortgage Payment Calculator {
^
[hint]Java class names can not contain spaces[/hint]
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200706/1
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "pacvek" <pacvek@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <1181701921.056031.172510@j4g2000prf.googlegroups.com> |
| In reply to | #1805 |
To: comp.lang.java.gui
On Jun 12, 7:23 pm, "Andrew Thompson" <u32984@uwe> wrote:
> pac...@aol.com wrote:
> >hi everyone, I'm new to the java world ...
>
> An inappropriate time to be taking on GUI'd applications.
>
> >...and I'm need of dire help,
>
> Best help for beginners is available on comp.lang.java.help
>
> >...I
> >have been given an assignment and for some reason I cannot compile, I
> >keep getting the same error ...
>
> What error? Always copy/paste compile and runtime
> error output.
>
> >...and even when I add an extra bracket the
> >error gets greater, here is the program and hopefully someone can help
> >me out.
>
> >import java.text.DecimalFormat;
>
> >public class Mortgage Payment Calculator {
>
> D:\MortgagePaymentCalculator.java:3: '{' expected
> public class Mortgage Payment Calculator {
> ^
>
> [hint]Java class names can not contain spaces[/hint]
>
> --
> Andrew Thompsonhttp://www.athompson.info/andrew/
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-gui/200706/1
Thanks Andrew, I closed the gaps and still this thing is making fun of
me, still getting the same error
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Lew" <lew@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <jYydncMgENp6y_LbnZ2dnUVZ_q_inZ2d@comcast.com> |
| In reply to | #1804 |
To: comp.lang.java.gui
pacvek@aol.com wrote:
> hi everyone, I'm new to the java world and I'm need of dire help, I
> have been given an assignment and for some reason I cannot compile, I
> keep getting the same error and even when I add an extra bracket the
> error gets greater, here is the program and hopefully someone can help
> me out.
>
> import java.text.DecimalFormat;
>
> public class Mortgage Payment Calculator {
...
> }
>
>
> }
>
> }
> }
> }
You should really cite all the information, including the full, *copied* and
pasted error message, within the body of the message, rather than merely
hinting at it in the subject. Nonetheless, it is clear what your difficulty is.
The error said '{' (left brace) expected, not right brace ('}'), so clearly
adding right braces will not help. Adding more right braces would help even
less. Why did you think right braces would help an error that refers to left
braces?
Where would the compiler expect a left brace? The first place is just after
the class name in the class declaration:
> public class Mortgage Payment Calculator {
but instead of a left brace, the compiler finds a token 'Payment' - whoops, a
left brace '{' expected, but not found!
You have three class names in the declaration instead of only one. Just use one.
--
Lew
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "pacvek" <pacvek@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <1181703020.162653.40640@d30g2000prg.googlegroups.com> |
| In reply to | #1806 |
To: comp.lang.java.gui
On Jun 12, 7:31 pm, Lew <l...@lewscanon.nospam> wrote:
> pac...@aol.com wrote:
> > hi everyone, I'm new to the java world and I'm need of dire help, I
> > have been given an assignment and for some reason I cannot compile, I
> > keep getting the same error and even when I add an extra bracket the
> > error gets greater, here is the program and hopefully someone can help
> > me out.
>
> > import java.text.DecimalFormat;
>
> > public class Mortgage Payment Calculator {
> ...
> > }
>
> > }
>
> > }
> > }
> > }
>
> You should really cite all the information, including the full, *copied* and
> pasted error message, within the body of the message, rather than merely
> hinting at it in the subject. Nonetheless, it is clear what your difficulty is.
>
> The error said '{' (left brace) expected, not right brace ('}'), so clearly
> adding right braces will not help. Adding more right braces would help even
> less. Why did you think right braces would help an error that refers to left
> braces?
>
> Where would the compiler expect a left brace? The first place is just after
> the class name in the class declaration:
>
> > public class Mortgage Payment Calculator {
>
> but instead of a left brace, the compiler finds a token 'Payment' - whoops, a
> left brace '{' expected, but not found!
>
> You have three class names in the declaration instead of only one. Just use one.
>
> --
> Lew- Hide quoted text -
>
> - Show quoted text -
/*
MortgagePaymentCalculatorCR1.java
*/
import java.text.DecimalFormat;
public class MortgagePaymentCalculatorCR1.java:3:{
//initialize numerical values
public static void main(String[] args)
//declared variables
int loanamount = 200000;
double MP;
double Principal=200000;
int[] months= new int[3];
months[0] = 84;
months[1] = 180;
months[2] = 360;
//calculate
double[] interestrate= new double[3];
interestrate[0] = .0535;
interestrate[1] = .0550;
interestrate[2] = .0575;
DecimalFormat twoplaces = new DecimalFormat("0,000.00");
//calculate
System.out.println("\tPayment Calculator\n");
//looping in progress
for(int counter = 1; counter <=12; counter++)
//calculate
PayMonthly = (loantotal * interestRate[i] / (1 - Math.pow(1/(1 +
interestRate[i]),loanlength[i]*12)));
//calculate
System.out.println("\tLoan Amount 1 = " + loanamount);
System.out.println("\tYear Term is = " + yearterm[counter]);
System.out.println("\tInterest Rate = " +
interestrate[counter]*100);
System.out.println("\tMonthly Payment is " + twoplaces.format(MP));
}
this is what I have done so far and the following errors are
'{' expected line 7
'}' expected line 55
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Lew" <lew@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <FOadndb-C9y0wfLbnZ2dnUVZ_vDinZ2d@comcast.com> |
| In reply to | #1808 |
To: comp.lang.java.gui
pacvek@aol.com wrote:
> /*
> MortgagePaymentCalculatorCR1.java
>
> */
> import java.text.DecimalFormat;
>
> public class MortgagePaymentCalculatorCR1.java:3:{
This is just plain wrong. You don't put colons or periods in class names.
What are you using to teach you the language? Doesn't it explain what the
valid characters are for Java identifiers?
--
Lew
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "pacvek" <pacvek@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <1181703775.478818.158120@o11g2000prd.googlegroups.com> |
| In reply to | #1809 |
To: comp.lang.java.gui
On Jun 12, 7:53 pm, Lew <l...@lewscanon.nospam> wrote:
> pac...@aol.com wrote:
> > /*
> > MortgagePaymentCalculatorCR1.java
>
> > */
> > import java.text.DecimalFormat;
>
> > public class MortgagePaymentCalculatorCR1.java:3:{
>
> This is just plain wrong. You don't put colons or periods in class names.
>
> What are you using to teach you the language? Doesn't it explain what the
> valid characters are for Java identifiers?
>
> --
> Lew
I think I missed that one, I'm really not very good at this, I got rid
of the colons and periods and now I'm getting
';' expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
<identifier> expected
illegal start of type
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Lew" <lew@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <26ydnSsPMpf3wvLbnZ2dnUVZ_rjinZ2d@comcast.com> |
| In reply to | #1810 |
To: comp.lang.java.gui
pacvek@aol.com wrote:
> On Jun 12, 7:53 pm, Lew <l...@lewscanon.nospam> wrote:
>> pac...@aol.com wrote:
>>> /*
>>> MortgagePaymentCalculatorCR1.java
>>> */
>>> import java.text.DecimalFormat;
>>> public class MortgagePaymentCalculatorCR1.java:3:{
>> This is just plain wrong. You don't put colons or periods in class names.
>>
>> What are you using to teach you the language? Doesn't it explain what the
>> valid characters are for Java identifiers?
>>
>> --
>> Lew
>
> I think I missed that one, I'm really not very good at this, I got rid
> of the colons and periods and now I'm getting
>
> ';' expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> <identifier> expected
> illegal start of type
> <identifier> expected
> <identifier> expected
> <identifier> expected
> <identifier> expected
> <identifier> expected
Once again, *copy* and paste the *entire* error message, along with the SSCCE
(simple, self-contained correct (compilable) example) that causes it. We
can't keep guessing at what the trouble is with incomplete information.
--
Lew
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "pacvek" <pacvek@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <1181704461.247236.225300@x35g2000prf.googlegroups.com> |
| In reply to | #1810 |
To: comp.lang.java.gui
On Jun 12, 8:02 pm, pac...@aol.com wrote:
> On Jun 12, 7:53 pm, Lew <l...@lewscanon.nospam> wrote:
>
>
>
>
>
> > pac...@aol.com wrote:
> > > /*
> > > MortgagePaymentCalculatorCR1.java
>
> > > */
> > > import java.text.DecimalFormat;
>
> > > public class MortgagePaymentCalculatorCR1.java:3:{
>
> > This is just plain wrong. You don't put colons or periods in class names.
>
> > What are you using to teach you the language? Doesn't it explain what the
> > valid characters are for Java identifiers?
>
> > --
> > Lew
>
> I think I missed that one, I'm really not very good at this, I got rid
> of the colons and periods and now I'm getting
>
> ';' expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> <identifier> expected
> illegal start of type
> <identifier> expected
> <identifier> expected
> <identifier> expected
> <identifier> expected
> <identifier> expected- Hide quoted text -
>
> - Show quoted text -
okay here it is.
F:\New Folder\MortgagePaymentCalculatorCR1.java:53: <identifier>
expected
System.out.println("\tMonthly Payment is " +
twoplaces.format(MP));
^
20 errors
Process completed.
--------------------Configuration: <Default>--------------------
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
Process completed.
--------------------Configuration: <Default>--------------------
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
Process completed.
--------------------Configuration: <Default>--------------------
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
Process completed.
';' expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
']' expected
<identifier> expected
<identifier> expected
illegal start of type
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Lew" <lew@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <4fKdnaK8AOn4__LbnZ2dnUVZ_tXinZ2d@comcast.com> |
| In reply to | #1812 |
To: comp.lang.java.gui
pacvek@aol.com wrote:
> okay here it is.
>
> F:\New Folder\MortgagePaymentCalculatorCR1.java:53: <identifier>
> expected
> System.out.println("\tMonthly Payment is " +
> twoplaces.format(MP));
> ^
> 20 errors
>
> Process completed.
>
> --------------------Configuration: <Default>--------------------
Meaningless garbage snipped
> Process completed.
> ';' expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> ']' expected
> <identifier> expected
> <identifier> expected
> illegal start of type
> <identifier> expected
> <identifier> expected
> <identifier> expected
> <identifier> expected
> <identifier> expected
<http://www.physci.org/codes/sscce.html>
<http://mindprod.com/jgloss/sscce.html>
--
Lew
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <2IadnQowiuyHzO3bnZ2dnUVZ8qminZ2d@bt.com> |
| In reply to | #1808 |
To: comp.lang.java.gui
pacvek@aol.com wrote:
>
> /*
> MortgagePaymentCalculatorCR1.java
>
> */
> import java.text.DecimalFormat;
>
> public class MortgagePaymentCalculatorCR1.java:3:{
>
>
>
> //initialize numerical values
> public static void main(String[] args)
snip
> '{' expected line 7
> '}' expected line 55
>
You've allowed yourself to be driven by the error messages without
really understanding them. I found it a bad idea, as a beginner, to
write 100 lines of java and then try compiling it.
Start with this - does it compile?
/*
* MortgagePaymentCalculator.java
*/
public class MortgagePaymentCalculator {
public static void main (String[] args) {
System.out.println("Mortgage Payment Calculator");
}
}
A good way for a beginner to work is to not add any extra code to the
above until it compiles. Then add no more than two or three lines. Get
that to compile before proceeding. Proceed in tiny steps.
If it compiles, what do you expect as output? Try running it and see if
the actual output is as you expect. Don't add new functionality until
the existing prototype behaves exactly how you expect.
Use indentation to help you see the structure of the program.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Lew" <lew@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <i62dnZEOnpq24u3bnZ2dnUVZ_gCdnZ2d@comcast.com> |
| In reply to | #1829 |
To: comp.lang.java.gui
RedGrittyBrick wrote:
> You've allowed yourself to be driven by the error messages without
> really understanding them. I found it a bad idea, as a beginner, to
> write 100 lines of java and then try compiling it.
>
> Start with this - does it compile?
>
> /*
> * MortgagePaymentCalculator.java
> */
> public class MortgagePaymentCalculator {
> public static void main (String[] args) {
> System.out.println("Mortgage Payment Calculator");
> }
> }
>
> A good way for a beginner to work is to not add any extra code to the
> above until it compiles. Then add no more than two or three lines. Get
> that to compile before proceeding. Proceed in tiny steps.
>
> If it compiles, what do you expect as output? Try running it and see if
> the actual output is as you expect. Don't add new functionality until
> the existing prototype behaves exactly how you expect.
>
> Use indentation to help you see the structure of the program.
What RedGrittyBrick is teaching you is also the way to put together an SSCCE.
--
Lew
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <89vu63p415nbqm05fthpu2pabfpnaom9a4@4ax.com> |
| In reply to | #1804 |
To: comp.lang.java.gui here is some generic advice: 1. use an IDE that formats your code. It makes bracketing errors much easier to see. See http://mindprod.com/jgloss/ide.html 2. look up error messages at http://mindprod.com/jgloss/errormessages.html -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "kaldrenon" <kaldrenon@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <1181840741.945390.119290@n15g2000prd.googlegroups.com> |
| In reply to | #1804 |
To: comp.lang.java.gui
> double MP;
MP is declared here, but it never gets initialized. So when you use
it, your program will explode (not literally)
> double[] interestrate= new double[3];
> interestrate[0] = .0535;
> interestrate[1] = .0550;
> interestrate[2] = .0575;
Just a small readability comment, you can have capitals in variable
names. interestRate is easier to read, no?
> for(int counter = 1; counter <=12; counter++);
> {
> //calculate
Uh oh. See that semicolon? That's breaking your code. When you do a
for loop in Java, there are two options for what follows: either a
block noted by {}, or a single line that ends with ;. What you're
doing here is telling Java "Do everything after for() but before ; 12
times," or, in your case, "Do nothing 12 times". As a result, in all
of the code you have in the {} block below, i isn't initialized, and
this code will only run once instead of 12 times, like you want.
>
> PayMonthly = (loantotal * interestRate[i] / (1 - Math.pow(1/(1 +
> interestRate[i]),loanlength[i]*12)));
PayMonthly needs to be given a type the first time it's referenced. It
looks like you've got two variables to do the same job (MP and
PayMonthly) but if you only use each half of the time, neither gets
the job done.
Side note: general coding practice (at least in Java) is to name
variables and methods with lowercase first, classes with proper case,
and constants with all upper case.
Hope that helps some. And people are right - it helps others help you
if you're clear and specific about the problem you're having. Too
little and people can't help, too much and there's garbage to sort
through to find the problem.
Good luck,
Andrew
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Aziz" <aziz@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <1181848774.259839.284540@d30g2000prg.googlegroups.com> |
| In reply to | #1835 |
To: comp.lang.java.gui
On Jun 14, 1:05 pm, kaldrenon <kaldre...@gmail.com> wrote:
> > double MP;
>
> MP is declared here, but it never gets initialized. So when you use
> it, your program will explode (not literally)
>
> > double[] interestrate= new double[3];
> > interestrate[0] = .0535;
> > interestrate[1] = .0550;
> > interestrate[2] = .0575;
>
> Just a small readability comment, you can have capitals in variable
> names. interestRate is easier to read, no?
>
> > for(int counter = 1; counter <=12; counter++);
> > {
> > //calculate
>
> Uh oh. See that semicolon? That's breaking your code. When you do a
> for loop in Java, there are two options for what follows: either a
> block noted by {}, or a single line that ends with ;. What you're
> doing here is telling Java "Do everything after for() but before ; 12
> times," or, in your case, "Do nothing 12 times". As a result, in all
> of the code you have in the {} block below, i isn't initialized, and
> this code will only run once instead of 12 times, like you want.
>
>
>
> > PayMonthly = (loantotal * interestRate[i] / (1 - Math.pow(1/(1 +
> > interestRate[i]),loanlength[i]*12)));
>
> PayMonthly needs to be given a type the first time it's referenced. It
> looks like you've got two variables to do the same job (MP and
> PayMonthly) but if you only use each half of the time, neither gets
> the job done.
>
> Side note: general coding practice (at least in Java) is to name
> variables and methods with lowercase first, classes with proper case,
> and constants with all upper case.
>
> Hope that helps some. And people are right - it helps others help you
> if you're clear and specific about the problem you're having. Too
> little and people can't help, too much and there's garbage to sort
> through to find the problem.
>
> Good luck,
> Andrew
I would recommend going to your local library or book store and
getting a book on Java. Either that, or read the Java Tutorials:
http://java.sun.com/docs/books/tutorial/
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "JT" <jt@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <4671d627$0$4305$9a566e8b@news.aliant.net> |
| In reply to | #1840 |
To: comp.lang.java.gui
Aziz wrote:
> On Jun 14, 1:05 pm, kaldrenon <kaldre...@gmail.com> wrote:
>>> double MP;
>> MP is declared here, but it never gets initialized. So when you use
>> it, your program will explode (not literally)
>>
>>> double[] interestrate= new double[3];
>>> interestrate[0] = .0535;
>>> interestrate[1] = .0550;
>>> interestrate[2] = .0575;
>> Just a small readability comment, you can have capitals in variable
>> names. interestRate is easier to read, no?
>>
>>> for(int counter = 1; counter <=12; counter++);
>>> {
>>> //calculate
>> Uh oh. See that semicolon? That's breaking your code. When you do a
>> for loop in Java, there are two options for what follows: either a
>> block noted by {}, or a single line that ends with ;. What you're
>> doing here is telling Java "Do everything after for() but before ; 12
>> times," or, in your case, "Do nothing 12 times". As a result, in all
>> of the code you have in the {} block below, i isn't initialized, and
>> this code will only run once instead of 12 times, like you want.
>>
>>
>>
>>> PayMonthly = (loantotal * interestRate[i] / (1 - Math.pow(1/(1 +
>>> interestRate[i]),loanlength[i]*12)));
>> PayMonthly needs to be given a type the first time it's referenced. It
>> looks like you've got two variables to do the same job (MP and
>> PayMonthly) but if you only use each half of the time, neither gets
>> the job done.
>>
>> Side note: general coding practice (at least in Java) is to name
>> variables and methods with lowercase first, classes with proper case,
>> and constants with all upper case.
>>
>> Hope that helps some. And people are right - it helps others help you
>> if you're clear and specific about the problem you're having. Too
>> little and people can't help, too much and there's garbage to sort
>> through to find the problem.
>>
>> Good luck,
>> Andrew
>
> I would recommend going to your local library or book store and
> getting a book on Java. Either that, or read the Java Tutorials:
> http://java.sun.com/docs/books/tutorial/
>
Like what I'm doing right now is alternating between "The Java
Programming Language Fourth Edition" for basic stuff, and "Effective
Java" for more advanced stuff. Both good books and both "From the Source"
Another excellent book is Head First Java, part of the Head First Series
published by O'Reilly.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "pacvek" <pacvek@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:35 +0000 |
| Message-ID | <1181873133.547087.129490@q19g2000prn.googlegroups.com> |
| In reply to | #1843 |
To: comp.lang.java.gui
On Jun 14, 4:57 pm, JT <jtlinux1@yaho#Akd9i30.ca> wrote:
> Aziz wrote:
> > On Jun 14, 1:05 pm, kaldrenon <kaldre...@gmail.com> wrote:
> >>> double MP;
> >> MP is declared here, but it never gets initialized. So when you use
> >> it, your program will explode (not literally)
>
> >>> double[] interestrate= new double[3];
> >>> interestrate[0] = .0535;
> >>> interestrate[1] = .0550;
> >>> interestrate[2] = .0575;
> >> Just a small readability comment, you can have capitals in variable
> >> names. interestRate is easier to read, no?
>
> >>> for(int counter = 1; counter <=12; counter++);
> >>> {
> >>> //calculate
> >> Uh oh. See that semicolon? That's breaking your code. When you do a
> >> for loop in Java, there are two options for what follows: either a
> >> block noted by {}, or a single line that ends with ;. What you're
> >> doing here is telling Java "Do everything after for() but before ; 12
> >> times," or, in your case, "Do nothing 12 times". As a result, in all
> >> of the code you have in the {} block below, i isn't initialized, and
> >> this code will only run once instead of 12 times, like you want.
>
> >>> PayMonthly = (loantotal * interestRate[i] / (1 - Math.pow(1/(1 +
> >>> interestRate[i]),loanlength[i]*12)));
> >> PayMonthly needs to be given a type the first time it's referenced. It
> >> looks like you've got two variables to do the same job (MP and
> >> PayMonthly) but if you only use each half of the time, neither gets
> >> the job done.
>
> >> Side note: general coding practice (at least in Java) is to name
> >> variables and methods with lowercase first, classes with proper case,
> >> and constants with all upper case.
>
> >> Hope that helps some. And people are right - it helps others help you
> >> if you're clear and specific about the problem you're having. Too
> >> little and people can't help, too much and there's garbage to sort
> >> through to find the problem.
>
> >> Good luck,
> >> Andrew
>
> > I would recommend going to your local library or book store and
> > getting a book on Java. Either that, or read the Java Tutorials:
> >http://java.sun.com/docs/books/tutorial/
>
> Like what I'm doing right now is alternating between "The Java
> Programming Language Fourth Edition" for basic stuff, and "Effective
> Java" for more advanced stuff. Both good books and both "From the Source"
>
> Another excellent book is Head First Java, part of the Head First Series
> published by O'Reilly.- Hide quoted text -
>
> - Show quoted text -
Thank you everyone, I really appreciate all of your help, I may not
know how to ask the right question since I'm merely a begginer.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Message-ID | <icl883hr8p56g8kfi3uvh7l1ebs50d6mrt@4ax.com> |
| In reply to | #1844 |
To: comp.lang.java.gui On Thu, 14 Jun 2007 19:05:33 -0700, pacvek@aol.com wrote, quoted or indirectly quoted someone who said : >Thank you everyone, I really appreciate all of your help, I may not >know how to ask the right question since I'm merely a begginer. so was everyone else at one point. There is no shame in it. -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web