help w/ Eclipse needed - errors w/ curly braces and ;
I am sorry if i have posted this in the wrong section, but I'm new here and this seemed the most logical place to me.
I am very new to programming, and to the Eclipse environment. I have had this problem before, and am having it now with Eclipse that it will not accept my curly braces, and sometimes my ;.
It has an error saying it expects } to complete method body, or { expected after this token. I don't have the specifics on the ;, but it gets flagged too. As far as I can tell I have the punctuation in the correct place, but it will not run. It will also pop up an error periodically saying the default setting have changed and ask if I would like to retrieve the default settings or ignore. I don't know that I've made any changes, so I restore the defaults, and then my auto-corrections seem to work better. Do you think I need to re-download the program? I am running version 3.6.0.
Here is my code if you want to double check me... maybe I am crazy, or really not doing as well as I thought I was. I've indicated the areas where errors are with // to the right side of the lines its occuring.
Code java:
public class Exercise41 extends CashRegister {
public static void main(String[] args) { // get error here for {
private static final double QUARTER_VALUE = 0.25; // declare constant
private static final double DIME_VALUE = 0.10; // declare constant
private static final double NICKEL_VALUE = 0.05;//declares constant
private static final double PENNY_VALUE = 0.001; // declares constant
}
public class CashRegister { // get error here for }
this.CashRegister = new CashRegister();
register.recordPurchase(20.37);
register.enterDollars(20);
register.enterQuarters(2);
System.out.println("Change: " + register.GiveChange());
System.out.prinln("Expected: 0.13");
}
}
Re: help w/ Eclipse needed - errors w/ curly braces and ;
You have quite a few syntax errors in your code.
Code java:
public class Exercise41 extends CashRegister//extending an inner class of itself?
....
this.CashRegister = new CashRegister();//where is the variable? What is 'this' referring to?
....
register.recordPurchase(20.37);//Where are these methods defined?
register.enterDollars(20);
register.enterQuarters(2);
//static variables declared inside a method?
Re: help w/ Eclipse needed - errors w/ curly braces and ;
Quote:
Originally Posted by
copeg
You have quite a few syntax errors in your code.
Ah copeg just beat me to it. I was going to say the same thing..
This isn't an Eclipse error. Eclipse is your friend :)
I think you need to start over with this. Let us know where you need help...
Re: help w/ Eclipse needed - errors w/ curly braces and ;
Don't forget the typo error here:
Code Java:
System.out.prinln("Expected: 0.13");
Should be:
Code Java:
System.out.println("Expected: 0.13");