Hi All,
I'm just learning Java and have written this simple program and need help in understanding while the output for the numbers in the range that should print out retiree,child, and teenager all print out, "You are an adult." I understand why when I type in symbols or letters I get, "You
are a retiree."
Thanks for your help.
Here's the code:
import java.io.*;
public class Mike {
public static void main(String[] args) {
System.out.println("Type your age here ");
int a = 0;
try {
a = (int)System.in.read(); }
catch(IOException e) {
System.out.println(a + "\t"); }
if (a < 13)
System.out.println ("You are a child.");
else if (a < 18)
System.out.println("You are a teenager.");
else if (a < 65)
System.out.println("You are an adult.");
else
System.out.println("You are a retiree.");
}
}
Mike B.