Can't figure out my errors

So 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);

}
}

Comments

  • The program works for me, just remember to add import java.util.*; at the beginning of the program, otherwise the Scanner won't work
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion