Friday, May 14, 2010

How ill i create a program that will allow the user to input an age and the computer will indicate?

if it is Baby,Child,Teenager,Adult,Senior Citizen using the if statementHow ill i create a program that will allow the user to input an age and the computer will indicate?
Depends what language you are using.How ill i create a program that will allow the user to input an age and the computer will indicate?
It depends what language you're using, the user before me has a point. The basic outline is this:


1. Get input from the user.


2. Run it through an if...elseif...else loop or a switch loop (switch/case) to set a string variable saying whether they're a baby, child, teenager, adult, or a senior citizen. Use greater than (%26gt;) and less than (%26lt;) signs.


3. Print/echo the variable.





Good luck!
if age %26lt; 2 then Generation = ';Infant'; else if age %26lt; 13 then Generation = ';Child'; else if age %26lt; 21 then Generation = ';Adult'; else age %26lt; 65 then Generation = ';Senior';


Hope this helps...
Choose your programming language





Get their age. Then use a few if then else statements to output something based. This is PHP





if { $age =%26lt; 12}


{echo ';Your are a child';;}


elseif{ $age %26gt;= 13 %26amp;%26amp; $age %26lt;= 20}


{echo ';You are a teenager';;}





and so on...

No comments:

Post a Comment