• Make Order

  • order processing

  • Approve and Get
    your Order
Order Now

Assignment

1. [prob1.c] [80%] Your computer pretends to be 20 years older than you. Create a program that asks
for your age, adds twenty years to your age, and outputs the following “smiley face”
(^_^)
Your program should output the following 5 lines:
– Line 1: Ask user to input age, and user inputs age value XX
– Line 2: Output smiley face
– Line 3: Output text, I am your computer! My name is SMILEY.
– Line 4: Output text, I am YY years old. You are 20 years younger than me.
– Line 5: Output text, See you next time. Bye!
Where XX is a user-input value and YY is a calculated value based on that user-input value.
Below is an example of your programs output, where the number 21 is users input and the number
41 is a calculated value based on that user-input value.
In your report, discuss the limitation of the input value. What happens if the user inputs a value of
the following cases?
i) A negative number (e.g. -5)
ii) An excessively large number (e.g. 9876543210)
iii) A number with decimal fraction (e.g. 15.6)
iv) An alphabet letter (e.g. A)

2. [prob2.c] [20%] Duplicate the program you created in Problem 1. Add the following modifications:
a) Prompt the user to limit the input age value between 0 and 100.
b) Add a validity check after the user has input an age value. If the user-input age value is between
0 and 100, inclusively, then the program continues. If not, the program outputs a message
notifying the user that the input is an invalid value and the program stops.
Below is an example of your programs output when the user-input age value is invalid.
In your report, discuss the effectiveness of your validity check. Does it resolve any limitation
mentioned in Problem 1?

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes