The Box - PowerPoint PPT Presentation

About This Presentation
Title:

The Box

Description:

The Box – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 16
Provided by: SusanMi6
Category:
Tags: box | class

less

Transcript and Presenter's Notes

Title: The Box


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
The Box - Inputs and Outputs
  • Inputs
  • height
  • width
  • depth
  • Outputs
  • volume
  • surface area
  • height
  • width
  • depth

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
The Box - Final Pseudocode
  • Display Enter the height
  • Read ltheightgt
  • While (ltheightgt lt 0 )
  • Display The height must be gt 0
  • Display Enter the height
  • Read ltheightgt
  • End_while

5
The Box - Final Pseudocode (cont)
  • Display Enter the width
  • Read ltwidthgt
  • While (ltwidthgt lt 0 )
  • Display The width must be gt 0
  • Display Enter the width
  • Read ltwidthgt
  • End_while

6
The Box - Final Pseudocode (cont)
  • Display Enter the depth
  • Read ltdepthgt
  • While (ltdepthgt lt 0 )
  • Display The depth must be gt 0
  • Display Enter the depth
  • Read ltdepthgt
  • End_while

7
The Box - Final Pseudocode (cont)
  • ltvolumegt ltheightgt X ltwidthgt X ltdepthgt
  • ltsurface1gt ltheightgt X ltwidthgt
  • ltsurface2gt ltwidthgt X ltdepthgt
  • ltsurface3gt ltheightgt X ltdepthgt
  • ltsurface areagt 2 X (ltsurface1gt
    ltsurface2gt

  • ltsurface3gt)

8
The Box - Final Pseudocode (cont)
Display Height , ltheightgt Display Width ,
ltwidthgt Display Depth , ltdepthgt Display
Volume , ltvolumegt Display Surface Area ,
ltsurface areagt
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
The Rectangle - Inputs and Outputs
  • Inputs
  • height
  • width
  • Outputs
  • height
  • width
  • the drawing of the rectangle

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
The Rectangle - Final Pseudocode
  • Display Enter the height
  • Read ltheightgt
  • While (ltheightgt lt 0 )
  • Display The height must be gt 0
  • Display Enter the height
  • Read ltheightgt
  • End_while

13
The Rectangle - Final Pseudocode (cont)
  • Display Enter the width
  • Read ltwidthgt
  • While (ltwidthgt lt 0 )
  • Display The width must be gt 0
  • Display Enter the width
  • Read ltwidthgt
  • End_while

14
The Rectangle - Final Pseudocode (cont)
  • Display Height , ltheightgt
  • Display Width , ltwidthgt
  • Skip a line

15
The Rectangle - Final Pseudocode (cont)
  • ltheight countergt 1
  • While ( ltheight countergt lt ltheightgt )
  • ltwidth countergt 1
  • While ( ltwidth countergt lt ltwidthgt )
  • Display
  • ltwidth countergt ltwidth countergt 1
  • End_while
  • Place cursor on next line
  • ltheight countergt ltheight countergt 1
  • End_while
Write a Comment
User Comments (0)
About PowerShow.com