import java.io.*;
// An application with a class that provides information about a person’s
age and voting eligibility.
class People
{
public static void main (String [] args)
{
Person person
= new Person ();
person.readData
();
person.votingAge
();
} // main method
} // class People
// Class that stores information about a person's name and age.
class Person
{
private String name;
private double age;
// A method to read data from the keyboard.
It uses a buffered reader.
public void readData ()
{
try
{
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
System.out.print ("Name: ");
name = stdin.readLine ();
System.out.print ("Age: ");
age = Double.valueOf (stdin.readLine ()).doubleValue ();
}
catch (IOException
e) { System.out.println ("I/O error");}
catch (NumberFormatException
ex) { System.out.println ("Number format error.");}
} // method readData
// Method that decides whether or not a person
is old enough to vote..
public void votingAge ()
{
if (age >= 18.0)
System.out.println (name + " is old enough to vote.");
else
System.out.println (name + " is still too young to vote.");
} // method votingAge
} // class Person