Professional Documents
Culture Documents
SOLUTION
First establish your inputs and your outputs, and then develop your IPO chart.
Remember: this phase is called - Analysis Of The Problem.
So what are your inputs & output? :
Variable names:
Number of items (input & output) Num (Assume there are 4 items)
In your IPO chart, you will describe the logical steps to move from your inputs to your outputs.
Note that there are some variables that are neither input nor output. These variable are either constants which are used
in your calculations (TaxRate & Discount), or necessary resulting variables which are not displayed, since they were
are not required to be shown (ItemTotalN).
We now convert the IPO chart to pseudocode (i.e. write an algorithm). In other words, we will model our program
from our analysis. After that, there is the testing phase (which we will bypass for this exercise), and finally the actual
program code in Pascal Programming Language.
ALGORITHM (in pseudocode) {Note: anything written in braces {}is a comment and not part of the program}
If TaxedTotal > 450 then {if statement to decide whether discount is applicable}
DiscTaxedTotal ² TaxedTotal - Discount {calculate discounted total}
Print: TotPrice, Tax, DiscTaxedTotal, TaxedTotal, Num {display required data}
Else
Print: TotPrice, Tax, TaxedTotal, Num
{end if statement}
Print: “Thank you, have a good day”
Stop
-----**** Next page: the actual code in Pascal programming language ***----
PROGRAM PriceCalc;
{A program to calculate the total cost of items}
{Author: Howard D Jones}
{Date: 2012 - 05 - 24}
Begin
Price1:=0.0; Price2:=0.0; Price3:=0.0; Price4:=0.0;
ItemTotal1:=0.0; ItemTotal2:=0.0; ItemTotal3:=0.0; ItemTotal4:=0.0;
Num:=0; Quan1:=0; Quan2:=0; Quan3:=0; Quan4:=0;
TotPrice:=0.0; DiscTaxedTotal:=0.0; TaxedTotal:=0.0;
End.