1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: "illegal start of expression" -- I've checked -- what am I missing?

Discussion in 'Software Development' started by Baronwyn, Jul 6, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. Baronwyn

    Baronwyn Thread Starter

    Joined:
    Jul 6, 2012
    Messages:
    9
    System is PC Win 7 SP1 64-bit for what that's worth in this situation. I'm a rank beginner in Java, pretty new to programming in general. The following code (within a larger program) generates 4 "illegal start of expression" errors (lines marked).

    I've matched my brackets for the entire program, there are no methods within methods. Notice that all four errors are on "if" statements with logical operators && and ||. The code lines with a simple > don't throw errors. Am I using the operators wrong?

    Thank you!

    if (gender == "f")
    {
    if (age >= 25 && <= 29) //error 1
    System.out.println("The female renter is " + age + " years old. The rate class is: Rate 1 - $50.00 per day or $255.00 " +
    "per week.");
    else
    if (age >=30 && <= 62) //error 2
    System.out.println("The female renter is " + age + " years old. The rate class is: Best rate - 40.00 per day or " +
    "$200.00 " + "per week.");
    else
    if (age > 62)
    System.out.println("The female renter is " + age + " years old. The rate class is: Rate 3 - " + (40 + ((age-62) * 2)) +
    " per day or " + (200 + ((age-62) * 5)) + " per week.");
    else
    System.out.println("Sorry, the renter is not 25 years of age or older.");
    }
    else
    {
    if (age >= 25 && <= 32) //error 3
    System.out.println("The male renter is " + age + " years old. The rate class is: Rate 2 - $57.00 per day or $285.00 " +
    "per week.");
    else
    if (age >= 33 || <= 65) //error 4
    System.out.println("The male renter is " + age + " years old. The rate class is: Best rate - 40.00 per day or " +
    "$200.00 per week.");
    else
    if (age > 65)
    System.out.println("The male renter is " + age + " years old. The rate class is: Rate 3 - " + (40 + ((age-65) * 2)) +
    " per day or " + (200 + ((age-65) * 5)) + " per week.");
    else
    System.out.println("Sorry, the renter is not 25 years of age or older.");
    }
     
  2. Baronwyn

    Baronwyn Thread Starter

    Joined:
    Jul 6, 2012
    Messages:
    9
    I figured out the problem. A noob syntax error. I cleared those all up and eagerly hit Compile only to be hit with a lot more errors. This program needs more work before a single Q&A will fix it. Thanks anyway and good luck to everyone.
     
  3. ssye894

    ssye894

    Joined:
    Jul 5, 2012
    Messages:
    7
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1059973