This is the first programming assignment, and it requires you to write the pseudocode for a program that gets the radius and height of a cylinder from the user, and then calculates the volume of the cylinder by using the following formula:
Volume = radius * radius * height * 3.1416
Once calculated, the volume of the cylinder is displayed to the user.
Please read the problem description carefully so that you know exactly what the program is supposed to do. Understanding the problem is part of the programming process. Follow the program requirements precisely. You may want to ask yourself the following questions about this problem:
- What input does the program need to get from the user?
- How do I use the given input to calculate the volume of the cylinder?
- What information needs to be displayed to the user after the calculations have been completed?
As stated in the Instructor Policies, your pseudocode must conform to the syntax and style of the pseudocode examples in our textbook.
Before attempting this problem, read Chapters 1 and 2, and pay special attention to how the Sale Price problem is analyzed and solved throughout Chapter 2. The complete pseudocode that solves the Sale Price problem is listed on Chapter 2, page 83, and that pseudocode is the equivalent of what you need to provide for the Volume of a Cylinder program.
After reading Chapters 1 and 2, look at Worksheet D under the “Worksheets” thread in the Course Materials Forum. Worksheet D also gives a completed example of the Sale Price problem you can use as a guide. Your assignment only needs to provide the pseudocode for the Volume of a Cylinder program that you will be writing, not the analysis.
This is your first attempt at writing a program, so remember the following hints as you write your pseudocode:
- Every program needs to have a Main Module.
- Consider breaking down the problem into smaller modules to make the solution easier, and use the Call statement to call those modules when needed.
- Determine what variables will be needed, and use the Declare statement to declare all variables and their data types properly before they are used.
- Once a variable is declared, use its name throughout the program exactly as it is declared.
- Use the Input statement to get any input required from the user.
- Use the Set statement to set values to variables.
- Use the Write statement to display output to the user.
Here is the example of the pseudocode that is needed to complete this assignment:
Example 2.6 The Complete Sale Price Program Design
Declare ItemName As String
Declare OriginalPrice As Float
Declare DiscountRate As Float
Declare Tax As Float
Declare SalePrice As Float
Declare TotalPrice As Float
Write “Sale Price Program”
Write “This program computes the total price, including tax, of”
Write “an item that has been discounted a certain percentage.”
Call Input Data module
Call Perform Calculations module
Call Output Results module
Input Data module
Write “What is the item’s name?”
Write “What is its price and the percentage discounted?”
Perform Calculations module
Declare AmountSaved As Float
Set AmountSaved = OriginalPrice * (DiscountRate/100)
Set SalePrice = OriginalPrice – AmountSaved
Set Tax = SalePrice * .065
Set TotalPrice = SalePrice + Tax
Output Results module
Write “The item is: “ + ItemName
Write “Pre-sale price was: “ + OriginalPrice
Write “Percentage discounted was: “ + DiscountRate + “%”
Write “Sale price: “ + SalePrice
Write “Sales tax: “ + Tax
Write “Total: $” + TotalPrice