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);
}
}
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).
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.
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.*" ?