CMIS 102-6387
May 30, 2015
Program description: I calculated the usable area in square feet of a house. Assume that the house has a maximum of four rooms, and that each room is rectangular. I wrote pseudo code statements to declare 4 Integers and labeled them homesqft, room1, room2, room3, and room4. Each room will have its length and width to calculate its area.
Analysis:
Test Case #
Input
Expected Output
1
Room1: length=10, width=14
Room2: length=9, width=10
Room3: length=12, width=12
542 sqft
2
Room1: length=10, width=10
Room2: length=11, width=12
Room3: length=11, width=12
Room4: length=13, width=14
546 sqft
3
Room1: length=8, width=10
Room2: length=10, width=12
Room3: length=11, width=14
Room4: length=12, width=14 …show more content…
#include <stdio.h>
2. int main(void) {
3.
4. float homesqft;
5. float room1;
6. float room2;
7. float room3;
8. float room4;
9. float room1_length;
10. float room1_width;
11. float room2_length;
12. float room2_width;
13. float room3_length;
14. float room3_width;
15. float room4_length;
16. float room4_width;
17.
18.
19. room1_length = 10;
20. room1_width = 10;
21. room2_length = 11;
22. room2_width = 12;
23. room3_length = 11;
24. room3_width = 12;
25. room4_length = 13;
26. room4_width = 14;
27.
28. room1 = room1_length * room1_width;
29. room2 = room2_length * room2_width;
30. room3 = room3_length * room3_width;
31. room4 = room4_length * room4_width;
32.
33. homesqft = room1+room2+room3+room4;
34.
35. printf("Square footage is %f", homesqft );
36.
37. return 0;
38. }
39.
Test Case #3 Pseudo code
1. #include <stdio.h>
2. int main(void) {
3.
4. float homesqft;
5. float room1;
6. float room2;
7. float room3;
8. float room4;
9. float room1_length;
10. float room1_width;
11. float room2_length;
12. float room2_width;
13. float room3_length;
14. float room3_width;
15. float room4_length;
16. float room4_width;
17.
18.
19. room1_length = 8;
20. room1_width =