Top Banner
 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)
19

Tugasan MTS3013 Pengaturcaraan Berstruktur

Jun 02, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 1/19

PENGATURCARAAN BERSTRUKTUR

(MTS 3013)

ASSIGNMENT 1

MUTIARA INDAH COMPANY DISCOUNT SYSTEM

MUHAMAD BASYIR BIN MAT NAWI

(D20122061847)

SEMESTER 1(SESI 2012/2013)

PENSYARAHPROFESOR MADYA DR. NOR HASBIAH BINTI UBAIDULLAH

FAKULTI SENI, KOMPUTERAN DAN INDUSTRI KREATIF(FSKIK)

Page 2: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 2/19

MUTIARA INDAH COMPANY DISCOUNT SYSTEM

1 Problem Analysis:

1.1 Input

Based on the information given by the company, the discount system should applyaccordingly 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 BoughtUnit 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;

Page 3: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 3/19

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

Page 4: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 4/19

2 Flowchart:

Page 5: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 5/19

Page 6: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 6/19

Page 7: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 7/19

Page 8: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 8/19

Page 9: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 9/19

3 Program Source Code:

LINE

1 #include <iostream.h>2 void main () 3 { 4 5 int unit = 0 ; //Declaration for unit boughts6 char response ; //Declaration for flag option

7

float price=

0.00,

pay,

discount=

0.00,

tprice,

discount_given;

//Declaration for price, total afterdiscount (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 unit14 cin >> unit ; 15 cout << "Enter price: \tRM" ; //Input price16 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 928 } 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 932 } 33 else 34 {

Page 10: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 10/19

35 discount = 0.05 ; //Set discount to 0.05 if price above RM100.00 when unitrange is 0 to 9

36 } 37 } 38 else 39 { 40 cout << "\tInvalid price" << endl ; //Warn a user when input price is less than zero41 } 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 9951 } 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 9955 } 56 else 57 { 58 discount = 0.09 ; //Set discount to 0.09 if price above RM100.00 when unit

range is 10 to 9959 } 60 } 61 else 62 { 63 cout << "\tInvalid price" << endl ; //Warn a user when input price is less than zero64 } 65 } 66 else if ( unit <= 499 ) 67 { 68 if ( price >= 0 ) 69 { 70 if ( price <= 10.00 ) 71 {

Page 11: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 11/19

72 discount = 0.09 ; //Set discount to 0.09 if price RM0.00 to RM10.00 whenunit 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 49977 } 78 else 79 { 80 discount = 0.21 ; //Set discount to 0.21 if price above RM100.00 when unit

range is 100 to 49981 } 82 } 83 else 84 { 85 cout << "\tInvalid price" << endl ; //Warn a user when input price is less than zero86 } 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 99995 }

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 99999 } 100 else 101 { 102 discount = 0.32 ; //Set discount to 0.32 if price above RM100.00

when unit range is 500 to 999103 } 104 } 105 else 106 {

Page 12: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 12/19

107 cout << "\tInvalid price" << endl ; //Warn a user when input price is lessthan 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 999117 } 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 999121 } 122 else 123 { 124 discount = 0.43 ; //Set discount to 0.43 if price above RM100.00

when unit range is above 999125 } 126 } 127 else 128 { 129 cout << "\tInvalid price" << endl ; //Warn a user when input price is less

than zero130 } 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 negative136 } 137 138 tprice = price * unit ; //Calculate total full cost139 discount_given = tprice * discount ; //Calculate total discount given140 pay = tprice - discount_given ; //Calculate total after discount141

Page 13: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 13/19

142 cout << "\t TOTAL COST: \t|RM" << tprice << endl ; //total full cost143 cout << "\t-DISCOUNT: \t|RM" << discount_given << endl ; //discount given144 cout << "\t _________________________________" << endl ; 145 cout << "\t PAYMENT: \t|RM" << pay << endl ; //total after discount146 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 beginning152 cin >> response ; 153 154 if ( response == 'y' || response == 'Y' ) 155 { 156 cout << "NEW SESSION" << endl ; //Display output when user continue using the system157 } 158 else if ( response == 'n' || response == 'N' ) 159 { 160 cout << "Exiting the system..." << endl ; //Display output when user exiting the

system161 } 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 flag166 }

167 } 168 } while ( response == 'y' || response == 'Y' ); //Starting a new calculation session169 }

Page 14: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 14/19

4 Testing Phase:

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

Page 15: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 15/19

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

Page 16: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 16/19

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

Page 17: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 17/19

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

Page 18: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 18/19

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

Page 19: Tugasan MTS3013 Pengaturcaraan Berstruktur

8/10/2019 Tugasan MTS3013 Pengaturcaraan Berstruktur

http://slidepdf.com/reader/full/tugasan-mts3013-pengaturcaraan-berstruktur 19/19

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