Lab 2
Lab 2
1. Write an expression that will cause the following code to print "30 or less" if the value of
user input is 30 or less. (20%)
Test Case 1
Test No Input Output
1 30 30 or less
2 25.6 30 or less
3 54 Over 30
4 102.3 Over 30
2. Write a program that reads a floating-point number and prints “zero” if the number is zero.
Otherwise, print “positive” or “negative”. Add “small” if the absolute value of the number is less
Test Case
1 0 zero
1 The specified test cases can be used to evaluate the effectiveness of the program. Furthermore, you are required to design and
run your own test case as well at the Peer-review phase of the lab assignment.
1|Page
Lab 2
If year is 2101 or later, print "Distant future" (without quotes). Otherwise, if year is 2001 or
greater, print "21st century". Otherwise, if year is 1901 or greater, print "20th century". Else
Test Case
2|Page
Lab 2
4. Write a program whose inputs are three integers, and whose output is the smallest of
Test Case
1 2, 5, 5 2
2 0, -10, 2 -10
5. Write a program that reads a temperature value and the letter C for Celsius or F for Fahrenheit. Print
whether water is liquid, solid, or gaseous at the given temperature at sea level. (20%)
a. Test Case
Test No Input Output
3|Page