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: Can't figure out my error

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Can't figure out my error

    Pretty new to Java but having a little trouble. I've done three different programs involving if statements and I can't figure out why I keep getting an error message "one or more projects are compiled with errors" on any of the programs. I've tested all three and each scenario and if i bypass the error they all run correctly. Here is one of the programs. Any help would be greatly appreciated thanks!

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

    Scanner scan = new Scanner(System.in);

    int age, time;
    double rate;
    final double matineeChildren = 2.00;
    final double regularChildren = 4.00;
    final double matineeAdult = 5.00;
    final double regularAdult = 8.00;

    System.out.println("How old are you? ");
    age = scan.nextInt();

    System.out.println("What time is it? ");
    time = scan.nextInt();

    if (age < 12)
    {
    if (time < 1630)
    rate = matineeChildren;
    else
    rate = regularChildren;

    }

    else
    {
    if (time < 1630)
    rate = matineeAdult;
    else
    rate = regularAdult;
    }

    System.out.println("Your rate is " + rate);

    }
    }


  2. #2
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Can't figure out my error

    Hello bigtrouble187!
    The above code has no error. Probably the other two programs you mentioned have errors. What do you mean "bypass the error"?
    Please post the code that has the error and the full error message (because "one or more projects are compiled with errors" looks like and IDE message and is missing information such as what the error is and in which line it occured).

  3. The Following User Says Thank You to andreas90 For This Useful Post:

    bigtrouble187 (May 26th, 2012)

  4. #3
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Can't figure out my error

    Thanks for the response, yeah I didn't think it had errors but everytime i compile the file on netbeans it gives me that message and allows me to "run program anyways". Not sure why though.

  5. #4
    Junior Member
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can't figure out my error

    I could be wrong, but I see that you used the Scanner:
    "Scanner scan = new Scanner(System.in);"

    Don't you have to import "java.util.*" ?

Similar Threads

  1. I can't figure out why i keep getting this error
    By chrissy2860 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 17th, 2011, 03:06 PM
  2. [SOLVED] Simple error that I can't figure out how to fix
    By javapenguin in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 11th, 2011, 07:27 AM
  3. just one more error that i cannot figure out please help me.
    By knoxy5467 in forum What's Wrong With My Code?
    Replies: 31
    Last Post: June 14th, 2011, 09:04 AM
  4. Simple error can't figure out.
    By n00bprogrammer in forum What's Wrong With My Code?
    Replies: 14
    Last Post: September 30th, 2010, 12:19 PM
  5. Can not figure out my programs error!
    By mparkerj in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 16th, 2010, 09:48 AM