Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: help w/ Eclipse needed - errors w/ curly braces and ;

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question 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.

     
    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");
    		}
     
    	}
    Last edited by rbread80; October 7th, 2010 at 11:59 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: help w/ Eclipse needed - errors w/ curly braces and ;

    You have quite a few syntax errors in your code.
    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?

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: help w/ Eclipse needed - errors w/ curly braces and ;

    Quote Originally Posted by copeg View Post
    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...
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: help w/ Eclipse needed - errors w/ curly braces and ;

    Don't forget the typo error here:

    System.out.prinln("Expected: 0.13");

    Should be:

    System.out.println("Expected: 0.13");
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Replies: 24
    Last Post: August 4th, 2014, 12:49 PM
  2. Many Errors
    By Woody619 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: July 16th, 2010, 09:36 PM
  3. Getting errors
    By Nonire in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 4th, 2010, 12:21 PM
  4. Curly braces or semicolon?
    By SweetyStacey in forum Java Theory & Questions
    Replies: 7
    Last Post: May 7th, 2010, 06:34 AM
  5. getting errors needed to be clear
    By erinbasim in forum Enterprise JavaBeans
    Replies: 1
    Last Post: February 4th, 2010, 03:24 AM

Tags for this Thread