Do the necessary planning (IPO) and write an algorithm in pseudo code for the following
The user must enter a positive integer between 5 and 15. If this number is valid, the user must also choose between a triangle (T or t) and a square (S or s). Display suitable error messages if necessary; otherwise, the program must use an asterisk to draw a triangle or a square of the chosen size and display. Use a Select Case structure to make the decision. Display appropriate error messages where applicable.
display 'Enter positive integer x between 5 and 15:'
int x
if "5\\le x\\le 15" then
display 'Choose triangle (t) or square (s)'
case t:
draw a triangle using an asterisk
case s:
draw a square using an asterisk
case else:
display 'Error'
else if "x<5" or "x>15" then
display 'Error'
end
Comments
Leave a comment