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…
542 sqft
Main module Declare homesqft As Float Declare room1_length, room1_width, room2_length, room2_width, room3_length, room3_width, room4_length, room4_width As Float Call Input Data module Call Perform Calculations module Call Output Results module
End Module
Input Data module Write "Please enter Room 1 Length: " + room1_length Write "Please enter Room 1 Width: " + room1_width Write "Please enter Room 2 length: " + room2_length Write "Please enter Room 2 width: " + room2_width Write "Please enter Room 3 length: " + room3_length Write "Please enter Room 3 width: " + room3_width Write "Please enter Room 4 length: " + room4_length Write "Please enter Room 4 width: " + room4_width
Perform Calculations module Set room1_sqft = room1_length * Room1_width Set room2_sqft = room2_length * Room2_width Set room3_sqft = room3_length * room3_width Set room4_sqft = room4_length * room4_width Set homesqft = room1_sqft + room2_sqft + room3_sqft + room4_sqft Output Results module Write "The item is: " + homesqft
Test Case #1 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 = 10;
20. room1_width = 14;
21. room2_length = 9;
22. room2_width = 10;
23. room3_length = 12;
24. room3_width = 12;
25. room4_length = 12;
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. }
Test Case #2 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 = 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 =
10;
21. room2_length = 10;
22. room2_width = 12;
23. room3_length = 11;
24. room3_width = 14;
25. room4_length = 12;
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. }