IT 210 Week 2 Volume of a Cylinder Assignment
University of Phoenix Associates Program Material (revised by Albert Mink)
Worksheet D
System-Level Requirements Example
Consider the Sale Price problem from Chapter 2, page 75, in which you read what are often called system-level requirements—the basis for all subsequent analysis and design steps. The following steps will take these system-level requirements and refine them into analysis and pseudocode for the program.
Up to this point, you have identified the processes the program must perform, but you have not given any consideration to exactly how the processes work together to solve the problem. At this point, you must generate a description of the processing using pseudocode, a natural language description of the processing the application must perform.
The natural place to start is the system-level requirements you identified in the Input-Process-Output (IPO) chart. Determine how the processes work together: Once you have determined the top-level logic, you can then design each of the individual processes. It is this step-wise refinement process that allows you to conceptualize a vague problem into increasing levels of details in order to actually generate a working program. This point is important because the step-wise refinement pattern is used throughout the entire program development—each new piece of information is based on, and is a refinement of, the information uncovered in the previous step.
The following information demonstrates how to write a program to calculate the total cost of an item on sale (including the discount and sales tax). Comments in the program are prefixed with two forward slashes (//).
Analysis
Process:
1. Get user input
2. Calculate discount
3. Calculate discounted price
4. Calculate sales tax
5. Calculate total price
6. Display total price
ItemName (String)
OriginalPrice (Float)
DiscountPercentage (Float)
SalesTaxPercentage (Float)
User Input:
Output:
TotalPrice (Float)
Pseudocode
Main Module
// Declare global variables that are used in more than one module
Declare OriginalPrice As Float
Declare DiscountPercentage As Float
Declare Discount As Float
Declare SalesTaxPercentage As Float
Declare SalesTax As Float
Declare DiscountedPrice As Float
Declare TotalPrice As Float
// Call submodules
Call Get User Input Module
Call Calculate Discount Module
Call Calculate Discounted Price Module
Call Calculate Sales Tax Module
Call Calculate Total Price Module
Call Display Total Price Module
End Program
Get User Input Module
// Declare a local variable that is only used in this module
Declare ItemName As String
// State the purpose of the program to the user
Write “This program displays the total price of an item after “
Write “the discount and sales tax have been applied.”
// Get the name of the item
Write “What is the name of the item?”
Input ItemName
// Get the original price of the item from the user
Write “What is the original price?”
Input OriginalPrice
// Get the discount percentage from the user
Write “What is the discount percentage?”
Input DiscountPercentage
// Get the sales tax percentage from the user
Write “What is the sales tax percentage?”
Input SalesTaxPercentage
Calculate Discount Module
// Calculate the amount of the discount
Set Discount = OriginalPrice * DiscountPercentage / 100
Calculate Discounted Price Module
// Calculate the discounted price
Set DiscountedPrice = OriginalPrice - Discount
Calculate Sales Tax Module
// Calculate the amount of the sales tax
Set SalesTax = DiscountedPrice * SalesTaxPercentage / 100
Calculate Total Price Module
// Calculate the total price
Set TotalPrice = DiscountedPrice + SalesTax
Display Total Price Module
// Display the result to the user
Write “The total price of the “ + ItemName + “ is $” + TotalPrice
Sample Output
(User input to the program is displayed in bold.)
This program displays the total price of an item after
the discount and sales tax have been applied. What is the name of the item?
perfume
What is the original price?
30.00
What is the discount percentage?
20
What is the sales tax percentage?
6
The total price of the perfume is $25.44
IT 210