PDA

View Full Version : a simple program


looking_to_code
09-26-2009, 01:35 PM
I’m working on a Project that needs to verify that someone is 18 or older. If they are 18 or older it needs to display approved and if not display denied. I have written the code to give the age of a person. I have no idea how to make it display if they are 18 or older approve and if below 18 denied.

Here is what i have so far. any help i can would be most appreciated .

import java.io.*;
class customers age{
Public static void main (String args [])
{
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader bufRead = new BufferedReader(istream) ;

System.out.println("This is to verify you are 18 or older");

try{
System.out.println("Please Enter in Your First Name: "):
string firstName = bufRead.readLine ();

System.out.println("please Enter the Year You Were Born; ");
string bornYear = bufRead.readLine();

System.out.println('Please Enter the Current Year: ");
String thisYear = bufRead.readLine();

int bYear = Integer.parseInt(bornYear);
int tYear = Integer.parseInt(thisYear);

int age = tYear-bYear;
System.out.println("Hello " + firstName + "You are " + age + "years old");

}
catch (IOException err) {
System.out.println("Error reading line");
}
}
}

ckeyrouz
09-26-2009, 07:46 PM
Double posted I have already answered the other post:

http://www.codingforums.com/showthread.php?t=178067

looking_to_code
09-26-2009, 10:34 PM
sorry