This program explain about selling doughnut with programming C. This program has been include variabel, operator, control flow, function, array, string dan struct. To use this program : 1. Firstly, input username and password. I has set username = rizki and password = syaputra. If user input user and password wrong, program will display “Login Failed”. But if user name and password match program will display “Login succes” and go to main program 2. In main program, program has 2 menus. Menu Distributor and menu Selling Doughnut. Distrubutor to input data distributor, and selling doughnut for sell doughnut with price and total must paid. flowchart program :

donutsok

operator : total.strowbery= total.st1 * 3000; total.cokelat = total.ck1 * 2500; total.cheese= total.cs * 3500; struct :

struct sellingdoughnut{
int no;

float cheese;
float strowbery;
float cokelat;
float st1;
float ck1;
float cs;
char tKind[7];

}total;
struct distributor {
char no[10];
char name[10];
char tDonut[3];
}dst;

function :

void selling(){
int i, tChoice;
struct sellingdoughnut{
int no;

float cheese;
float strowbery;
float cokelat;
float st1;
float ck1;
float cs;
char tKind[7];

}total;

sel:
system("cls");
printf("\n\n");
printf("--------------------------------------------------------------\n");
printf("                       Selling Doughnut                       \n");
printf("\n\n");
printf("List of price doughnut :\n");
printf("1. Strowberry           Rp 3000\n");
printf("2. Cokelat              Rp 2500\n");
printf("3. Cheese               Rp 3500\n");
printf("\n\n");
printf("Doughnut strowberry           : ");
scanf("%f",&total.ck1);
printf("Doughnut cokelat              : ");
scanf("%f",&total.st1);
printf("Doughnut cheese               : ");
scanf("%f",&total.cs);

total.strowbery= total.st1 * 3000;
total.cokelat = total.ck1 * 2500;
total.cheese= total.cs * 3500;
printf("\n\n");
printf("Price for Dougnut strowberry : %.3f \n",total.strowbery);
printf("Price for Dougnut cokelat    : %.3f \n", total.cokelat);
printf("Price for Dougnut cheese     : %.3f \n",total.cheese);
printf("Total pay                    : %.3f \n",(total.strowbery+total.cokelat+total.cheese));
printf("\n\n");
printf("Thank you");
printf("\n\n");
printf("-------------------------------------------------------------------\n");
printf("Menu : \n");
printf("1. Input Distributor \n");
printf("2. Selling Donut \n");
printf("\n\n");
//system("cls");
printf("Please input menu : ");
scanf_s("%d",&tChoice);
switch(tChoice){
case 2:
goto sel;
break;
system("cls");
case 1:
distributor();
break;

}
}
void distributor(){
int tChoice;
struct distributor {
char no[10];
char name[10];
char tDonut[3];
}dst;

dist :
system("cls");
printf("\n\n");
printf("------------------DISTRIBUTOR DOUGNUT---------------------\n");
printf("No registrasi               : ");
scanf("%s",&dst.no);
printf("Name                        : ");
scanf("%s",&dst.name);
printf("Total Dougnouts             : ");
scanf("%s",&dst.tDonut);

printf("\n\n");
printf("--------------------- DATA DISTRIBUTOR ---------------\n\n");
printf("No registrasi            :                %s\n",dst.no);
printf("Name                     :                %s\n",dst.name);
printf("Total Donuts             :                %s\n",dst.tDonut);
printf("\n\n");

printf("------------------------------------------------------\n\n");
printf("Menu : \n");
printf("1. Input Distributor \n");
printf("2. Selling Donut \n");
printf("\n\n");
//system("cls");
printf("Please input menu : ");
scanf_s("%d",&tChoice);
switch(tChoice){
case 1:
goto dist;
break;
system("cls");
case 2:
selling();
system("pause");
break;
}
}

below is full syntax program :

#include
#include
#include

void distributor();
void selling();

void selling(){
int i, tChoice;
struct sellingdoughnut{
int no;

float cheese;
float strowbery;
float cokelat;
float st1;
float ck1;
float cs;
char tKind[7];

}total;

sel:
system("cls");
printf("\n\n");
printf("--------------------------------------------------------------\n");
printf("                       Selling Doughnut                       \n");
printf("\n\n");
printf("List of price doughnut :\n");
printf("1. Strowberry           Rp 3000\n");
printf("2. Cokelat              Rp 2500\n");
printf("3. Cheese               Rp 3500\n");
printf("\n\n");
printf("Doughnut strowberry           : ");
scanf("%f",&total.ck1);
printf("Doughnut cokelat              : ");
scanf("%f",&total.st1);
printf("Doughnut cheese               : ");
scanf("%f",&total.cs);

total.strowbery= total.st1 * 3000;
total.cokelat = total.ck1 * 2500;
total.cheese= total.cs * 3500;
printf("\n\n");
printf("Price for Dougnut strowberry : %.3f \n",total.strowbery);
printf("Price for Dougnut cokelat    : %.3f \n", total.cokelat);
printf("Price for Dougnut cheese     : %.3f \n",total.cheese);
printf("Total pay                    : %.3f \n",(total.strowbery+total.cokelat+total.cheese));
printf("\n\n");
printf("Thank you");
printf("\n\n");
printf("-------------------------------------------------------------------\n");
printf("Menu : \n");
printf("1. Input Distributor \n");
printf("2. Selling Donut \n");
printf("\n\n");
//system("cls");
printf("Please input menu : ");
scanf_s("%d",&tChoice);
switch(tChoice){
case 2:
goto sel;
break;
system("cls");
case 1:
distributor();
break;

}
}

void distributor(){
int tChoice;
struct distributor {
char no[10];
char name[10];
char tDonut[3];
}dst;

dist :
system("cls");
printf("\n\n");
printf("------------------DISTRIBUTOR DOUGNUT---------------------\n");
printf("No registrasi               : ");
scanf("%s",&dst.no);
printf("Name                        : ");
scanf("%s",&dst.name);
printf("Total Dougnouts             : ");
scanf("%s",&dst.tDonut);

printf("\n\n");
printf("--------------------- DATA DISTRIBUTOR ---------------\n\n");
printf("No registrasi            :                %s\n",dst.no);
printf("Name                     :                %s\n",dst.name);
printf("Total Donuts             :                %s\n",dst.tDonut);
printf("\n\n");

printf("------------------------------------------------------\n\n");
printf("Menu : \n");
printf("1. Input Distributor \n");
printf("2. Selling Donut \n");
printf("\n\n");
//system("cls");
printf("Please input menu : ");
scanf_s("%d",&tChoice);
switch(tChoice){
case 1:
goto dist;
break;
system("cls");
case 2:
selling();
system("pause");
break;
}
}
int main(void){

int choice,compare,compare1;
char user[10], pwd[10], user_1[10], pwd_1[10];

strcpy(user,"rizki");
strcpy(pwd,"syaputra");

printf("----------------------------------------------------------------------------\n");
printf("                    Welcome to Doughnut Application                         \n\n");
printf("                        Program Selling Dougnout                            \n");
printf("-----------------------------------------------------------------------------\n");
printf("\n\n");
printf("Please input username       : ");
gets(user_1);
printf("Please input password       : ");
gets(pwd_1);

compare = strcmp(user,user_1);
compare1 = strcmp(pwd,pwd_1);

if(compare==compare1){
index :
printf("\n\n");
printf("Login Success !\n");
system("cls");
printf("-----------------------------------------------------------------------------\n");
printf("                               Dougnut Application                           \n");
printf("Menu : \n");
printf("1. Input Distributor \n");
printf("2. Selling Donut \n");
printf("3. Exit");
printf("\n\n");
printf("Please input for choice menu (1..3 )  : \n");
scanf_s("%d",&choice);
switch(choice){
case 1:
distributor();
system("pause");
break;
case 2:
selling();
system("pause");
return(0);
}

}if(compare != compare1){
printf("\n\n");
printf("Login Failed !\n");
printf(" User name and password not match! \n");
printf("Try Again");
}

system("pause");
return(0);

}

output program : 1

When username and password not macth

2

username and password match

3

Main application

4

Menu Distributor

5

Menu Selling Donuts

Watch video on youtube :

http://www.youtube.com/watch?v=uPqJj0j8X-Y&feature=youtu.be

Advertisements