CLASS EXAMPLE 2
So Yum is now in business! For a short time, there will be an introductory offer, where all food and
drink items will cost R50. The company requires a program that will receive input about a
customer’s order for a food/drink item, perform calculations and display output.
Input: the table number, the code for the food/drink item being ordered (for this introductory offer,
the code entered will be INTRO), and the number of those food/drink items the customer will be
ordering (the quantity). For this introductory offer, the customer can only order the INTRO
food/drink item.
The amount owing by the customer must be calculated and displayed. The amount owing is the
number of food/drink items multiplied by the cost per food/drink (for now the R50) with VAT added
(the VAT rate is 15%). The VAT amount should be displayed separately.
REQUIRED:
In class:
In lab session:
Test Plan, IPO Chart, Interface Design, Pseudocode, and Deskcheck
C# form and Coded Solution
CLASS EXAMPLE 2 SOLUTION
TESTPLAN
Objectives:
TTTPATAP
Constraints: time; no information about input
Assumptions: input is valid
Quantity is numeric.
Strategy:
Input
TableNo
Item Code
Quantity
Possible input values
any valid
INTRO
Any valid
Classes
none
Representative
examples
4
Expected Results
None
INTRO
230 Amount owing
4
30 Vat
IPO CHART
INPUT
TableNo
Item Code
Quantity
PROCESSING
display form/prompts
accept TableNo
Assign constants (at beg of program)
Accept Item code,Quantity
Calc amount owing, Vat
Display
OUTPUT
Amount owing
Vat Amount
How constant is a constant? Are there constants that change and those that never change?
How and why do we treat constants and variables differently in our programs?
INTERFACE DESIGN
SO YUM!
Table number
Item code
Quantity
Amount owing
PSEUDOCODE
ClassEg2Pgm
(display form)
VATRate = 0.15
INTROPrice = 50
Accept TableNo
Accept ItemCode
Accept Qty
AmtOwing =INTRORate* Qty
VatAmount = AmtOwing * VatRate
AmountOwing= AmtOwing +VatAmt
Display AmtOwing
Display VatAmt
END
VAT amount
DESKCHECK TABLE
STATEMENT
Display
Assign
Assign
Accept
Accept
Accept
Calculate
Calculate
Calculate
Display
Display
TableNo. ItemCode. Qty.
AmtOwing. VATAmt. VATRate. Price.
0.15
50
4
Intro
4
200
30
230
Yes
Yes
Messages
Yes