Sunday, May 20

Programming Technique...

hy sume,, pe cite chik skrg? haha,,, biase la, chik bz la,, skrg nie pn tgh pening kple, slalu je tido kol 6 ataupun 7 pg utk siapkan project dll... nie cntoh project yg chik buat, simple je p lau nak buat nie mesti kena ada codeblock..hehe,, bkn visual basic k.. :)


nie utk customer msukkan info n bla bla bla... ^


nie lak output bila admin nak bkak pe yg customer order :) ^

amboiii,,,dh tgk output utk customer n admin, skunk nie jom tgk coding dye lak,,msti kowang pening, so xnk pening, sila la copy paste kt codeblock anda sndri, try ye :)

==================ok start coding kt bwh nie ok :)====================

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int booking(); // function prototype/ function declaration

int main()
{
    int a;

    a=booking(); // calling a function
    return 0;
}

int booking() // define a function
{
    //declaration for time
    char currentime[20];
    char date[20];
    time_t clock;
    struct tm*timeinfo, ftimeinfo;
    int total=0;


    //declaration for info
    int selection;
    int a, i, x, y, z, buy, how_much, pickup, sure, see;
    char name[2][20];
    char address[3][20];
    char phone_num[11];

    do
   {
    menu:
    system("cls");

    printf("\n\nChoose want you want to order\n\n");
    printf("\n 1 = Tat Tulip : RM25");
    printf("\n 2 = Tat Nenas : RM18");
    printf("\n 3 = Almond London : RM25");
    printf("\n 4 = Semperit Cip : RM17");
    printf("\n 5 = Biskut Dam : RM15");
    printf("\n\nHow many you want to order?\t");//Input
    scanf("\n%i",&how_much);
    int c=how_much;

    for(i=1;i<=c;i++)
    {
    printf("\nPlease insert the no.%d order:",i);
    scanf("%d",&selection);

    //switch
   switch (selection)
    {
        case 1 :
        printf("Tat Tulip\tRM25\n");
        total=total+25;

        break;

        case 2 :
        printf("Tat Nenas\tRM18\n");
        total=total+18;
        break;

        case 3 :
        printf("Almond London\tRM25\n");
        total=total+25;
        break;

        case 4 :
        printf("Semperit Cip\tRM17\n");
        total=total+17;
        break;

        case 5 :
        printf("Biskut Damn\tRM15\n");
        total=total+15;
        break;

        default:goto menu;
    }
    }
        printf("\n\nTotal is =RM%d",total); //total how much customer
        printf("\n\n<1 for cash, 2 for card credit, 3 for check>");
        printf("\nDo you want buy with : ");
        scanf("%d", &buy);

        //if else for want to buy with what
        if (buy == 1)
        {
            printf("cash", buy);
        }
        else if (buy == 2)
        {
            printf("card credit", buy);
        }
        else
        {
            printf("check", buy);
        }

        //customer key in info for booking order
        printf("\n===========Customer Information======\n", i+1);
        fflush(stdin);
        printf("\nName : ");
        gets(name[20]);
        printf("\nAddress : ");
        gets(address[20]);
        printf("\nPhone No : ");
        scanf("%s", &phone_num);
        printf("\nOrder Date : ");
        time ( &clock);
        timeinfo = localtime( &clock);
        strftime(currentime, 20, "%I:%M %p", timeinfo);
        printf("\n\nTime :%s", currentime);
        strftime(date, 20, "%x", timeinfo);
        printf("\n\nDate : %s\n\n", date);
        printf("\nPick Up Date/Delivery : ");
        scanf("\n%i", &pickup);

        //file operation for read and write
        FILE *input; //declaration for file
        input = fopen("FileReceipt.txt", "w"); // create a file for each customer

        //Output for receipt  - output
        fprintf(input, "\n\n******************************************\n\n");
        fprintf(input, "\t\t\tAMIRAH ENTERPRISE\n");
        fprintf(input, "\t\t\tLot Pt 3798, Tmn Desa Melati,\n");
        fprintf(input, "\t\t\tJln Sedek Sg Durian,\n");
        fprintf(input, "\t\t\t18000 Kuala Krai,\n");
        fprintf(input, "\t\t\tKelantan.\n\n\n");
        fprintf(input, "  ");
        fprintf(input, "\nName : %s",name[20]);
        fprintf(input, "\nAddress : %s", address[20]);
        fprintf(input, "\nPhone No : %s", phone_num);
        fprintf(input, "\nOrder Date : ");
        time (&clock);
        timeinfo = localtime(&clock);
        strftime(currentime, 20, "%I:%M %p", timeinfo);
        fprintf(input, "\n\nTime :%s", currentime);
        strftime(date, 20, "%x", timeinfo);
        fprintf(input, "\nPickup Date/Delivery : %i", pickup);
        fprintf(input, "\nDo you want buy with : %i \t<1 for cash, 2 for credit card, 3 for check>", buy);
        fprintf(input, "\nOrder Booking : %c", selection);
        fprintf(input, "\nTotal : RM%d", total);

        printf("\nFileReceipt.txt has been succesfully created.");
        fclose(input); //close the file if all info successfully created

        printf("\n< 1 for see, 2 for dont want>");
        printf("\n\nDo you want to see your receipt?");// customer want to look what her buy
        scanf("%i", &see);
        if (see == 1)
        {
        printf("\n\n******************************************\n\n");
        printf("\t\t\tAMIRAH ENTERPRISE\n");
        printf("\t\t\tLot Pt 3798, Tmn Desa Melati,\n");
        printf("\t\t\tJln Sedek Sg Durian,\n");
        printf("\t\t\t18000 Kuala Krai,\n");
        printf("\t\t\tKelantan.\n\n\n");
        printf("  ");
        printf("\nName : %s",name[20]);
        printf("\nAddress : %s", address[20]);
        printf("\nPhone No : %s", phone_num);
        printf("\nOrder Date : ");
        time (&clock);
        timeinfo = localtime(&clock);
        strftime(currentime, 20, "%I:%M %p", timeinfo);
        printf("\n\nTime :%s", currentime);
        strftime(date, 20, "%x", timeinfo);
        printf("\nPickup Date/Delivery : %i", pickup);
        printf("\nDo you want buy with : %i \t<1 for cash, 2 for credit card, 3 for check>", buy);
        printf("\nOrder Booking : %c", selection);
        printf("\nTotal : RM%d", total);
        }
        else
        {
            printf("Okay :)");
        }

        //ask customer for continue or not, if want customer can click 1
        printf("\n\nYou want to change?");
        printf("0=Yes, 1=No");
        switch(sure)
        {
            case 1 :
            printf("Yes");
            break;

            case 2 :
            printf("No");
            break;
        }

        printf("\n\nAre you sure?");
        scanf("%i", &z);

        if (z==1) break;

        }while (z==0);

    getch();
    return 0;
}

 =========dh2 la, nie je coding yg chik buat,, hehe >.<==============
ckup la ye ckit nie,,, byk lg yg kn knew buat... bye, jmpa nati ya sume :)


2 comments :

  1. Anonymous20/5/12 17:47

    This comment has been removed by a blog administrator.

    ReplyDelete
  2. so kowang yg bkal msuk ump, n yg blja c programming 2, ley la ambik nie ye utk project kowang :)

    ReplyDelete