Algorithm to calculate dimensions and costs for a rectangular shaped pool
// welcome user to pool site
- // asking for width
- Repeat
- Ask user for width between 5m and 20m
- Get width
- If (width <=5) or (width => 20)
- Error message
- Until (width > 5) and (width < 20)
- // asking for length
- Repeat
- Ask user for length greater than width but less than 20m
- get length
- if (length < width) or (length > 40)
- error message
- until (length > width) and (length <=40)
- // asking for depth
- Repeat
- Ask user for depth between 2 and 5
- Get depth
- If (depth <= 2) or (depth > 5)
- Error message
- Until (depth > 2) and (depth <= 5)
- // calculating volume
- volume = (depth*length*width)
- // calculating perimeter
- perimeter = (2length*2width)
- // calculating area
- area = (length*width)
- // calculating surface are of pool
- surface area = (length*width) + (length*depth*2) + (width*depth*2)
- // printing out measurements
- Println (“Volume = ” volume)
- Println (“Perimeter = ” perimeter)
- Println (“Area = ” area)
- Println ("Surface are = " surface area of pool)
- // calculating cost with and without tax
- Costw = (width/10)
- Costl = (length/10)
- Costd = (depth/9)
- Cost of pool = (Costw + Costl + Costd)
-
- // Ask user if they want tiles for the inside of the pool
- Repeat
- Ask user to press 1 if they want tiles and 2 if not
- Get answer
- If (answer not = 1) or (answer not = 2)
- error message
- Until (answer = 1) or (answer = 2)
- // asking user for size of tiles
- Repeat
- Ask user to press 1 for 12x12 (inches) tiles, or 2 for 16x16 tiles
- get answer
- If (answer not = 1) or (answer not = 2)
- error message
- Until (answer = 1) or (answer = 2)
- // calculating amount of tiles needed
- if (tile size = 16x16)
- Tiles needed = (surface area*3.281) /1.78
- else
- Tiles needed = (surface area*3.281)
- // printing amount of tiles needed
- println ("Tiles needed = " Tiles needed)
- // calculating and printing tile price
- Tile price = (Tiles needed*2.79)
- println ("Tile price = $" Tile price)
- // calulating cost of pool + tiles
- GST = (5% of Cost of pool + Tile price)
- PST = (7% of Cost of pool + Tile price)
- Cost Total = (Cost of pool + Tile price + GST + PST)
- // printing cost
- Println (“Total cost = $” Cost Total)