0% found this document useful (0 votes)
51 views

Lab 1 Week 3 - Solution

The document contains instructions and pseudo-code for three programming activities: 1) Obtaining three numbers from the user, calculating their average, and displaying the result. 2) Obtaining two numbers from the user and displaying which is smaller. 3) Obtaining a series of positive numbers until the user enters -1, calculating their sum, and displaying the result. It also provides pseudo-code and a flowchart for a program to obtain rectangle dimensions, calculate area and perimeter, and display the results. Finally, it gives pseudo-code to calculate total living area needing carpeting based on input room dimensions.

Uploaded by

pedoqpop
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Lab 1 Week 3 - Solution

The document contains instructions and pseudo-code for three programming activities: 1) Obtaining three numbers from the user, calculating their average, and displaying the result. 2) Obtaining two numbers from the user and displaying which is smaller. 3) Obtaining a series of positive numbers until the user enters -1, calculating their sum, and displaying the result. It also provides pseudo-code and a flowchart for a program to obtain rectangle dimensions, calculate area and perimeter, and display the results. Finally, it gives pseudo-code to calculate total living area needing carpeting based on input room dimensions.

Uploaded by

pedoqpop
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Structured Programming & Database

LAB 1 WEEK 3 - SOLUTION


Activity #1

Obtain three numbers from the keyboard, compute the average of the
numbers and display the result.
1.
2.
3.
4.
5.
6.

Start
Declare variables
Get input from user number 1, number 2, and number 3
Calculate average of number 1, number 2, and number 3
Display average
End

Start

Number 1,
Number 2,
Number 3

Average = (Number 1 +
Number 2 + Number 3) / 3

Display
Average

End

Structured Programming & Database

Obtain two numbers from the keyboard, and determine and display which (if
either) is the smaller of the two numbers.

1.
2.
3.
4.
5.
6.

Start
Declare variables
Get input from user number 1 and number 2
Compare number 1 and number 2
Display the smaller number
End

Start

Number 1,
Number 2

Display Number
1 is smaller than
Number 2

Number 1 < Number 2

Display Number
1 is smaller than
Number 2

End

Structured Programming & Database

Obtain a series of positive numbers from the keyboard, and determine and
display the sum of the numbers. Assume that the user types the sentinel
value -1 to indicate end of data entry.
1.
2.
3.
4.
5.

Start
Declare variables
Initialize total value = 0
Get a number from user
If number is not equal to -1, go to step 6, otherwise go to
step 7
6. Calculate sum
7. Display sum of numbers
8. End

Structured Programming & Database

Activity #2
You were asked by your project leader to write a simple program that obtains the
lengths of the sides of a rectangle. The program calculates the area and perimeter
then prints lengths, the area and the perimeter. Prepare a pseudo-code and a
flowchart for the program.
1.
2.
3.
4.
5.
6.

Start
Declare variables
Get input length and width from user
Calculate area and perimeter
Display area and perimeter
End

Structured Programming & Database

Activity #3

Calculate Living Area


Write a pseudo-code for calcCarpeting, based on the following structure chart.

Algorithm calcCarpeting
Start
1. Prompt user for famRoom width
2. Read familyRoom width
3. Prompt user for famRoom length
4. Read famRoom length
5. famRoom area = famRoom width * famRoom length
6. Prompt user for dineLive width
7. Read dineLive width
8. Prompt user for dineLive length
9. Read dineLive length
10. dineLive area = dineLive width * dineLive length
11. Living areas = famRoom area + dineLive area
12 Prompt user for bedRoom width
13. Read bedRoom width
14. Prompt user for bedRoom length
15. Read bedRoom length
16. BedRoom area = bedRoom width * bedRoom length
17. Carpeting area = BedRoom area + Living areas
End Algorithm calcCarpeting

You might also like