0% found this document useful (0 votes)
92 views3 pages

Lab 2

The document outlines 5 programming tasks with test cases to evaluate programs that: 1. Prints if a user input number is 30 or less or over 30. 2. Reads a floating point number and prints if it's zero, positive/negative, and small/large. 3. Prints the century or future based on the year input. 4. Prints the smallest of three integer inputs. 5. Prints the state of water given a temperature and if it's in Celsius or Fahrenheit.

Uploaded by

stephanefokoua80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views3 pages

Lab 2

The document outlines 5 programming tasks with test cases to evaluate programs that: 1. Prints if a user input number is 30 or less or over 30. 2. Reads a floating point number and prints if it's zero, positive/negative, and small/large. 3. Prints the century or future based on the year input. 4. Prints the smallest of three integer inputs. 5. Prints the state of water given a temperature and if it's in Celsius or Fahrenheit.

Uploaded by

stephanefokoua80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

Your Test Case

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

than 1,000,000 or “large” if it exceeds 1,000,000. (20%)

Test Case

Test No Input Output

1 0 zero

2 2000002.56 large positive

3 -3020000 large negative

4 302 small positive

Your Test Case

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

3. Write an if-else statement with multiple branches.

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

(1900 or earlier), print "Long ago". (20%)

Test Case

Test No Input Output

1 2101 Distant future

2 1889 Long ago

3 2002 21st century

4 1901 20th century

Your Test Case

2|Page
Lab 2

4. Write a program whose inputs are three integers, and whose output is the smallest of

the three values. (20%)

Test Case

Test No Input Output

1 2, 5, 5 2

2 0, -10, 2 -10

3 -3050, -10000,-23 -10000

Your Test Case

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

1 0, c At that temperature, the water is liquid.

2 31, F At that temperature, the water is solid.

3 101, C At that temperature, the water is gaseous.

4 212, f At that temperature, the water is gaseous.

Your Test Case

3|Page

You might also like