Here is the complete program,
with the blank filled in correctly:
import java.io.*;
class BoxOffice
{
public static void main (String[] args)
throws IOException
{
BufferedReader stdin =
new BufferedReader (
new InputStreamReader(System.in));
String inData;
int age;
System.out.println("Enter your age:");
inData = stdin.readLine();
age = Integer.parseInt( inData );
if ( age < 17 )
{
System.out.println("Child rate.");
}
else
{
System.out.println("Adult rate.");
}
System.out.println("Enjoy the show.");
}
}
|
Here is what happens for one run of the program:
- The program prints "Enter your age".
- The user enters an age---21, for example.
- The 21 is converted from characters into int and put into the variable age.
- The condition age < 17 is tested.
- 21 < 17 is false.
- The false branch is executed: the program prints "adult rate".
- Execution continues with the statement after the false branch:
"Enjoy the show" is printed.
|