How Old Are You?
source link: http://programmingbydoing.com/a/how-old-are-you.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
- Author: Graham Mitchell
- Filename: HowOldAreYou.java
How Old Are You?
Make a program which displays a different message depending on the age given. Here are the possible responses:
- age is less than 16, say "You can't drive."
- age is less than 18, say "You can't vote."
- age is less than 25, say "You can't rent a car."
- age is 25 or over, say "You can do anything that's legal."
Here's a sample run. Notice that a person who is under 16 will display three messages, one for being under 16, one for also being under 18, and one for also being under 25.
Hey, what's your name? Billy_Corgan Ok, Billy_Corgan, how old are you? 17 You can't vote, Billy_Corgan. You can't rent a car, Billy_Corgan.
©2013 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK