Download presentation
Presentation is loading. Please wait.
Published byJasper Perkins Modified over 9 years ago
1
CMSC 104, Version 9/01 1 The Box Problem: Write an interactive program to compute and display the volume and surface area of a box. The program must also display the box dimensions. Error checking should be done to be sure that all box dimensions are greater than zero.
2
CMSC 104, Version 9/01 2 The Box - Inputs and Outputs Inputs: o height o width o depth Outputs o volume o surface area o height o width o depth
3
CMSC 104, Version 9/01 3 The Box - Rough Algorithm Get the height from the user, performing error checking Get the width from the user, performing error checking Get the depth from the user, performing error checking Compute the volume of the box Compute the surface area of the box Display the height, width, depth, volume, and surface area of the box
4
CMSC 104, Version 9/01 4 The Box - Final Pseudocode Display “Enter the height: “ Read While ( <= 0 ) Display “The height must be > 0” Display “Enter the height: “ Read End_while
5
CMSC 104, Version 9/01 5 The Box - Final Pseudocode (con’t) Display “Enter the width: “ Read While ( <= 0 ) Display “The width must be > 0” Display “Enter the width: “ Read End_while
6
CMSC 104, Version 9/01 6 The Box - Final Pseudocode (con’t) Display “Enter the depth: “ Read While ( <= 0 ) Display “The depth must be > 0” Display “Enter the depth: “ Read End_while
7
CMSC 104, Version 9/01 7 The Box - Final Pseudocode (con’t) = X X = X = 2 X ( + + )
8
CMSC 104, Version 9/01 8 The Box - Final Pseudocode (con’t) Display “Height = “, Display “Width = “, Display “Depth = “, Display “Volume = “, Display “Surface Area = “,
9
CMSC 104, Version 9/01 9 Drawing a Rectangle Problem: Write an interactive program that will draw a solid rectangle of asterisks (*). The program must also display the dimensions of the rectangle. Error checking must be done to be sure that the dimensions are greater than zero.
10
CMSC 104, Version 9/01 10 The Rectangle - Inputs and Outputs Inputs o height o width Outputs o height o width o the drawing of the rectangle
11
CMSC 104, Version 9/01 11 The Rectangle - Rough Algorithm Get the height from the user, performing error checking Get the width from the user, performing error checking Display the height and width Draw the rectangle
12
CMSC 104, Version 9/01 12 The Rectangle - Final Pseudocode Display “Enter the height: “ Read While ( <= 0 ) Display “The height must be > 0” Display “Enter the height: “ Read End_while
13
CMSC 104, Version 9/01 13 The Rectangle - Final Pseudocode (con’t) Display “Enter the width: “ Read While ( <= 0 ) Display “The width must be > 0” Display “Enter the width: “ Read End_while
14
CMSC 104, Version 9/01 14 The Rectangle - Final Pseudocode (con’t) Display “Height = “, Display “Width = “, Skip a line
15
CMSC 104, Version 9/01 15 The Rectangle - Final Pseudocode (con’t) = 1 While ( ) = 1 While ( ) Display “*” = + 1 End_while Place cursor on next line = + 1 End_while
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.