Sunteți pe pagina 1din 19

PENGATURCARAAN BERSTRUKTUR

(MTS 3013)

ASSIGNMENT 1
MUTIARA INDAH COMPANY DISCOUNT SYSTEM


MUHAMAD BASYIR BIN MAT NAWI
(D20122061847)

SEMESTER 1
(SESI 2012/2013)

PENSYARAH
PROFESOR MADYA DR. NOR HASBIAH BINTI UBAIDULLAH

FAKULTI SENI, KOMPUTERAN DAN INDUSTRI KREATIF
(FSKIK)

MUTIARA INDAH COMPANY DISCOUNT SYSTEM
1 Problem Analysis:
1.1 Input
Based on the information given by the company, the discount system should apply
accordingly to the Table 1.0 below when the sale officer input/enter the unit of purchased
item and price. So the input of the system is unit item and price.
Table 1.0
Number Bought
Unit Price (RM)
0 10.00 10.01 100.00 100.01
1 9 0% 2% 5%
10 99 5% 7% 9%
100 499 9% 15% 21%
500 999 14% 23% 32%
1000 21% 32% 43%
Input Declaration:
Unit item int unit;
Price float price;
Input screen:
Enter unit:
Enter price: RM
1.2 Process
As of the given information, the Mutiara Indah Company stated that their company needs
a system that are able to calculate and prints the total full cost, the discount given, and
the total after discount.
Process Declaration:
Discount float discount;
Total full cost float tprice;
Discount given float discount_given;
Total after discount float pay;

Process Formula:
Total full cost = Price Unit item tprice = price * unit;
Discount given = Total full cost Discount discount_given = tprice * discount;
Total after discount = Total full cost Discount given pay = tprice discount_given;
1.3 Output
Mutiara Indah Company needs a system that can prints the total full cost, the discount
given, and the total after discount.
Output Declaration:
Use/fetch the previous declaration.
Total full cost TOTAL COST float tprice;
Discount given TOTAL DISCOUNT float discount_given;
Total after discount PAYMENT float pay;
Output Screen:
TOTAL COST: |RM
TOTAL DISCOUNT: |RM
PAYMENT: |RM

2 Flowchart:










3 Program Source Code:
LINE
1 #include <iostream.h>
2 void main()
3 {
4
5 int unit=0;//Declaration for unit boughts
6 char response;//Declaration for flag option
7 float price=0.00, pay, discount=0.00, tprice, discount_given;//Declaration for price, total after
discount (pay), discount(discount), total full cost (tprice), discount given(discount_given)
8
9 do
10 {
11 cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|||MUTIARA INDAH|||<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<endl;
12 cout<<"================================================================================"<<endl;
13 cout<<"Enter unit: \t ";//Input unit
14 cin>>unit;
15 cout<<"Enter price: \tRM";//Input price
16 cin>>price;
17
18 cout<<"================================================================================"<<endl;
19 if (unit >= 1)
20 {
21 if (unit <= 9)
22 {
23 if (price >=0)
24 {
25 if (price <= 10.00)
26 {
27 discount = 0.00;//Set discount to 0.00 if price RM0.00 to RM10.00 when
unit range is 0 to 9
28 }
29 else if (price <= 100.00)
30 {
31 discount = 0.02;//Set discount to 0.02 if price RM10.01 to RM100.00 when
unit range is 0 to 9
32 }
33 else
34 {
35 discount = 0.05;//Set discount to 0.05 if price above RM100.00 when unit
range is 0 to 9
36 }
37 }
38 else
39 {
40 cout<<"\tInvalid price"<<endl;//Warn a user when input price is less than zero
41 }
42
43 }
44 else if (unit <= 99)
45 {
46 if (price >=0)
47 {
48 if (price <= 10.00)
49 {
50 discount = 0.05;//Set discount to 0.05 if price RM0.00 to RM10.00 when
unit range is 10 to 99
51 }
52 else if (price <= 100.00)
53 {
54 discount = 0.07;//Set discount to 0.07 if price RM10.01 to RM100.00 when
unit range is 10 to 99
55 }
56 else
57 {
58 discount = 0.09;//Set discount to 0.09 if price above RM100.00 when unit
range is 10 to 99
59 }
60 }
61 else
62 {
63 cout<<"\tInvalid price"<<endl;//Warn a user when input price is less than zero
64 }
65 }
66 else if (unit <= 499)
67 {
68 if (price >=0)
69 {
70 if (price <= 10.00)
71 {
72 discount = 0.09;//Set discount to 0.09 if price RM0.00 to RM10.00 when
unit range is 100 to 499
73 }
74 else if (price <= 100.00)
75 {
76 discount = 0.15;//Set discount to 0.15 if price RM10.01 to RM100.00 when
unit range is 100 to 499
77 }
78 else
79 {
80 discount = 0.21;//Set discount to 0.21 if price above RM100.00 when unit
range is 100 to 499
81 }
82 }
83 else
84 {
85 cout<<"\tInvalid price"<<endl;//Warn a user when input price is less than zero
86 }
87 }
88 else if (unit <= 999)
89 {
90 if (price >=0)
91 {
92 if (price <= 10.00)
93 {
94 discount = 0.14;//Set discount to 0.14 if price RM0.00 to RM10.00 when
unit range is 500 to 999
95 }
96 else if (price <= 100.00)
97 {
98 discount = 0.23;//Set discount to 0.23 if price RM10.01 to RM100.00 when
unit range is 500 to 999
99 }
100 else
101 {
102 discount = 0.32;//Set discount to 0.32 if price above RM100.00
when unit range is 500 to 999
103 }
104 }
105 else
106 {
107 cout<<"\tInvalid price"<<endl;//Warn a user when input price is less
than zero
108 }
109 }
110 else
111 {
112 if (price >=0)
113 {
114 if (price <= 10.00)
115 {
116 discount = 0.21;//Set discount to 0.21 if price RM0.00 to RM10.00
when unit range is above 999
117 }
118 else if (price <= 100.00)
119 {
120 discount = 0.32;//Set discount to 0.32 if price RM10.01 to
RM100.00 when unit range is above 999
121 }
122 else
123 {
124 discount = 0.43;//Set discount to 0.43 if price above RM100.00
when unit range is above 999
125 }
126 }
127 else
128 {
129 cout<<"\tInvalid price"<<endl;//Warn a user when input price is less
than zero
130 }
131 }
132 }
133 else
134 {
135 cout<<"\tUnit or Price can't be equal or less than zero"<<endl;//Warn a user when
input price less than zero or unit is negative
136 }
137
138 tprice=price*unit;//Calculate total full cost
139 discount_given=tprice*discount;//Calculate total discount given
140 pay=tprice-discount_given;//Calculate total after discount
141
142 cout<<"\t TOTAL COST: \t|RM"<<tprice<<endl;//total full cost
143 cout<<"\t-DISCOUNT: \t|RM"<<discount_given<<endl;//discount given
144 cout<<"\t _________________________________"<<endl;
145 cout<<"\t PAYMENT: \t|RM"<<pay<<endl;//total after discount
146 cout<<"\t _________________________________"<<endl;
147
cout<<"********************************************************************************"<<endl;
148
149 for (int a=0;a<1;a++)
150 {
151 cout<<"Start again? (Y/N): ";//Option to start a system from beginning
152 cin>>response;
153
154 if (response == 'y' || response == 'Y')
155 {
156 cout<<"NEW SESSION"<<endl;//Display output when user continue using the system
157 }
158 else if( response == 'n' || response == 'N')
159 {
160 cout<<"Exiting the system..."<<endl;//Display output when user exiting the
system
161 }
162 else
163 {
164 a--;
165 cout<<"Invalid input!!!\nKey in Y or N then press enter..."<<endl;//Warn user
when invalid character is used to reply to the option flag
166 }
167 }
168 }while ( response == 'y' || response == 'Y');//Starting a new calculation session
169 }

4 Testing Phase:

Figure 4.1: Testing system with unit 1 using difference price range.


Figure 4.2: Testing system with unit 10 using difference price range.


Figure 4.3: Testing system with unit 100 using difference price range.


Figure 4.4: Testing system with unit 500 using difference price range.


Figure 4.5: Testing system with unit 1000 and above with difference price range.


Figure 4.6: Testing system by entering invalid value to input console.

S-ar putea să vă placă și