Week 1 iLab - Part 2
Complete the following two programs:
Programming Problem 1
John wants to know the values of the area and perimeter of a rectangle. John can take measurements of the length and width of the rectangle in inches. John's measurements are expected to be accurate to within 0.1 inch.
1. Identify the inputs and outputs of the problem.
Inputs
Double Length
Double Width
Output:
Double Area
Double Perimeter
2. Identify the processing needed to convert the inputs to the outputs.
Area= length*width
Perimeter= 2*(length+width)
3. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report each output.
A. Declare input and output variable
B. read length and width
C. calculate area and the perimeter
D. output the variables
4. Identify two test cases, one using whole number values, and one using decimal number values. For each of the two test cases show what inputs you will use and what your expected outputs should be.
Expected:
Length | Width | Area | Perimeter | | | | | | | | | | | | |
Actual: Length | Width | Area | Perimeter | | | | | | | | | | | | |
5. Write the program to implement your algorithm. Test your program using your test cases. Did your program produce the values predicted in your test cases? Explain.
Programming Problem 2
Shirlee is working with a measurement tool that reports measurements in centimeters. Since Shirlee is unfamiliar with centimeters, she would like her centimeter measurements to be converted into yards, feet, and inches. She would also like the result to be properly rounded to the nearest inch. As an example, if the measurement is 312 centimeters, this should be converted to 3 yards, 1 foot, and 3 inches.
1. Identify the inputs and outputs of the problem.
Input: float centimeters
Output: the amount of centimeters to be converted
2. Identify the processing needed