Sie sind auf Seite 1von 11

STRUCTURED PROGRAMMING

SPG 0443
GROUP ASSIGNMENT

Title: Auto Reload Service


NAME:

XXX

TRADE:

XXX

TTO:

XXX

System Introduction
Generally, this system shows how an easy reload system is applied. By
using this system, it will ease both seller and consumer as it is prepared
together with the discount calculation. So, the seller did not need to use any
calculator. Thus, it will make the process of reloading your prepaid become
easier and faster. The making of the system’s coding is done step by step in
order to get a clear and easy-to-understand system. In other words, it contains
all the necessary data.

First, my group drafted the flowchart to show the flow of system. With
help of TTO, we manage to get the best system flowchart. Then, it comes on
how to make the coding. After some discussion among my group members, we
decided to use this three types of program which are Function, If statement
and Switch statement. We decided to use these three types of programs
because it is easier and simpler than the other program.

At first, we were having some difficulty to debug the program after the
coding was done. Many ways were counted and lastly we ask for TTO and
other classmate’s help to check and correct our coding. After correcting our
coding for few times, lastly, our task is done completely without any problems
anymore.

Flow of System
First thing first, the customer need to verify his/her type of prepaid. The
program will ask the customer to enter their cell phone number and his/her
requested reload amount. After the system get those inputs, a reload
confirmation will appear in order to get the correct input. After reload
confirmation is done, payment is made. For this step, it is divided into two
parts:

a) RM50 and below and

b) RM51 and above

For the first condition, no discount given and the program will straightly
proceed to giving balance process. In the other hand, for RM51 and above,
10% discount is given. Just after that, the program will proceed to balance. If
there is balance, the customer will get back his/her balance and the program is
finish.
System Flowchart

Start

Choose prepaid type

Enter hand phone number

Enter requested reload amount

RM50 and below Payment RM51 and above

Discount 10%

Pay amount

Yes No

Balance

Give balance

End
Switch statement coding

In the switch statement, a computer tests a variable consecutively against a list


of integer or character constants and then executes the statement or block of
statements that are associated with the specified constant after a match was
found. My group has chosen this type of program to perform two functions.
They are:

a) For the selection of prepaid type


switch(num){
case 1:
printf("your selection is Maxis\n");
printf("Enter your mobile number");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

case 2:
printf("your selection is Celcom\n");
printf("Enter your mobile number");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

case 3:
printf("Your selection is Digi\n");
printf("Enter your mobile number");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

case 4:
printf("Your Selection is Umobile\n");
printf("Enter your mobile number");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

default:
printf("Incorrect input. Please try again later\n");
break;
}
b) For confirming the reload amount agreed by the consumer.

switch (num2){

case 1:
printf("Thank you. Please wait for your reload\n");
break;

default:
printf("Thanks for coming. Please start back if you still wants
to reload your prepaid\n");
break;
}

If statement coding

If statement enables an expression to be tested and act according to how the


expression is evaluated. It is most suitable for real-time or interactive
application. So, we chose this function in:

a) the payment process


printf("Payment\n");
if(value>=51)
{
sum=value-(0.1*value);
printf("you got 10 percent discount for transaction more than
RM51\n");
printf("You have to pay RM %d\n",sum);
}

else
{
sum=value;
printf("You have to pay RM %d\n",sum);
}
b) in balance program

if(num3>sum)
{
balance2=num3-sum;
printf("Your balance is RM %d\n",balance2);
printf("Thank you\n");
}
if(num3<sum)
{
balance2=sum-num3;
printf("your payment is not enough. please pay RM%d
more\n",balance2);
}
else
printf("Thank you\n");
Full coding
#include "stdafx.h"
void type (void);
void request(void);
void payment (void);
void balance (void);
int value,sum,num3,balance2;
int num,num2,phone;

void main()
{
type();
}
void type(){
printf("Reload Your Mobile Here\n");
printf("\n\n");
printf("Choose your prepaid type\n");
printf("\n 1-Maxis\n 2-Celcom\n 3-Digi\n 4-Umobile\n");
scanf("%d",&num);
printf("you have entered %d\n",num);
switch(num){
case 1:
printf("your selection is Maxis\n");
printf("Enter your mobile number:\n");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

case 2:
printf("your selection is Celcom\n");
printf("Enter your mobile number:\n");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

case 3:
printf("Your selection is Digi\n");
printf("Enter your mobile number:\n");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

case 4:
printf("Your Selection is Umobile\n");
printf("Enter your mobile number:\n");
scanf("%d,&phone");
request();
payment ();
balance ();
break;

default:
printf("\nIncorrect input. Please try again later\n");
break;
}

}
void request(){
printf("Please enter your request amount\n");
scanf("%d",&value);
printf("You have entered %d\n",value);
printf("Please press 1 to confirm or other number to cancel your
reload amount\n");
scanf("%d",&num2);
switch (num2){

case 1:
printf("Thank you. Please wait for your reload\n");
break;

default:
printf("Thanks for coming. Please start back if you still wants
to reload your prepaid\n");
break;
}
}
void payment (){
printf("Payment\n");
if(value>=51)
{
sum=value-(0.1*value);
printf("you got 10 percent discount for transaction more than
RM51\n");
printf("You have to pay RM %d\n",sum);
}

else
{
sum=value;
printf("You have to pay RM %d\n",sum);
}
}
void balance (){

printf("enter payment:");
scanf("%d",&num3);
printf("You paid RM %d\n",num3);

if(num3>sum)
{
balance2=num3-sum;
printf("Your balance is RM %d\n",balance2);
printf("Thank you\n");
}
if(num3<sum)
{
balance2=sum-num3;
printf("your payment is not enough. please pay RM%d
more\n",balance2);
}
else
printf("Thank you\n");
}
The full coding is the combination of all functions that we have used in this
program. It consists of type, request, payment and balance program which
after compiling all programs, it become our final project, Auto Reload Service.
After all, the coding is about how a top up transaction is being carried out.
Starting with choosing the type of prepaid, it is proceed with entering mobile
phone number, reload amount and so on until it finishes by thanking the
customer who doing the transaction.

The output if the correct input in entered at the selecting prepaid type
program.

The output if wrong input in entered at the selecting prepaid type program.
The output if reload amount is below than RM50(no discount given)

The output if reload amount is more than RM50 (10 percent discount given)

The output if payment is not enough.

Das könnte Ihnen auch gefallen