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?
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
![](https://collepals.com/wp-content/plugins/posts-import/files/order-now-with-paypal.png)