0% found this document useful (0 votes)
14 views2 pages

15 Marker Dimensions

The document outlines a program that prompts the user to input the number of rooms in a house, ensuring the number is between 3 and 20. It collects room names and dimensions, calculates the area for each room, and determines the total and average area, as well as identifying the largest and smallest rooms. Finally, it outputs the details of each room along with the total area and average room size.
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)
14 views2 pages

15 Marker Dimensions

The document outlines a program that prompts the user to input the number of rooms in a house, ensuring the number is between 3 and 20. It collects room names and dimensions, calculates the area for each room, and determines the total and average area, as well as identifying the largest and smallest rooms. Finally, it outputs the details of each room along with the total area and average room size.
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
You are on page 1/ 2

// Input and validate the number of rooms

OUTPUT "Enter the number of rooms (3-20): "


INPUT Number
WHILE Number < 3 OR Number > 20
OUTPUT "Invalid. Please enter a number between 3 and 20: "
INPUT Number
ENDWHILE

// Input room details and calculate area


FOR i ← 0 TO Number - 1
OUTPUT "Enter name for room ", i + 1, ": "
INPUT Rooms[i]
OUTPUT "Enter length (m) for ", Rooms[i], ": "
INPUT Dimensions[i][0]
OUTPUT "Enter width (m) for ", Rooms[i], ": "
INPUT Dimensions[i][1]
// Calculate and store rounded area
Dimensions[i][2] ← ROUND(Dimensions[i][0] * Dimensions[i][1], 2)
ENDFOR

// Calculate total area and average


totalArea ← 0
FOR i ← 0 TO Number - 1
totalArea ← totalArea + Dimensions[i][2]
ENDFOR
average ← ROUND(totalArea / Number, 2)

// Find largest and smallest room indices


maxIndex ← 0
minIndex ← 0
FOR i ← 1 TO Number - 1
IF Dimensions[i][2] > Dimensions[maxIndex][2] THEN
maxIndex ← i
ENDIF
IF Dimensions[i][2] < Dimensions[minIndex][2] THEN
minIndex ← i
ENDIF
ENDFOR

// Output all rooms' details


OUTPUT "Room Details:"
FOR i ← 0 TO Number - 1
OUTPUT Rooms[i], ": Length = ", Dimensions[i][0], "m, Width = ", Dimensions[i][1], "m, Area =
", Dimensions[i][2], "m²"
ENDFOR

// Output largest and smallest rooms


OUTPUT "Largest Room: ", Rooms[maxIndex], " (", Dimensions[maxIndex][2], "m²)"
OUTPUT "Smallest Room: ", Rooms[minIndex], " (", Dimensions[minIndex][2], "m²)"

// Output total and average area


OUTPUT "Total Area of the House: ", totalArea, "m²"
OUTPUT "Average Room Size: ", average, "m²"

You might also like