Saturday, May 9, 2009

final EXAM...

adoiiii aiii....final exam dh nk dekat nie..mood nk study xdak lg nie...cmnew?this semester,aku amik 4 subjek..paper yg plg dekat adalah Program design on 18hb nie...huh!!segala galanya adalah coding..mampus aku!!subjek ni plg aku minat,tp dlm masa yg sama x suka jugak...susah bangat!!tapi kalo aku berjaya buat full coding,memang gempaq arr..

contohnya...

Would you like to continue? [Press 1 to continue] : 1
Enter flower code : R
Enter amount of stalks : 12
------------------------------------------------------
CUSTOMER BILL
------------------------------------------------------
Flower : ROSE
Price : 2.30
Stalks : 12
Total : 27.60
Discount : 2.76
Bill : 24.84
Would you like to continue? [Press 1 to continue] : 1
Enter flower code : L
Enter amount of stalks : 3
------------------------------------------------------
CUSTOMER BILL
------------------------------------------------------
Flower : LILY
Price : 2.00
Stalks : 3
Total : 6.00
Discount : 0.00
Bill : 6.00
Would you like to continue? [Press 1 to continue] : 1
Enter flower code : R
Enter amount of stalks : 22
------------------------------------------------------
CUSTOMER BILL
------------------------------------------------------
Flower : ROSE
Price : 2.30
Stalks : 22
Total : 50.60
Discount : 7.59
Bill : 43.01
Would you like to continue? [Press 1 to continue] : 0
------------------------------------------------------
DAILY SALES REPORT
------------------------------------------------------
Rose : 34 stalks
Tulip : 0 stalks
Lily : 3 stalks


cmna coding dia????


#include
#include
#define ROSE 2.30
#define TULIP 3.00
#define LILY 2.00
void main()

{

int choice, stalks, rose=0, tulip=0, lily=0;
char fcode, flower[20];
float payment, price, discount, discount_value, total;
printf("Would you like to continue? [Press 1 to continue] : ");
scanf("%d", &choice);
fflush(stdin);
while(choice == 1)

{

fflush(stdin);
printf("\nEnter flower code : ");
scanf("%c", &fcode);
fflush(stdin);
printf("Enter amount of stalks : ");
scanf("%d", &stalks);
switch(fcode)

{

case 'R' : strcpy(flower,"ROSE"); price=ROSE; rose+=stalks; break;
case 'T' : strcpy(flower,"TULIP"); price=TULIP; tulip+=stalks; break;
case 'L' : strcpy(flower,"LILY"); price=LILY; lily+=stalks; break;
default : strcpy(flower,"INVALID"); price=0.00; break;

}

if (stalks > 10 && stalks <=20) discount = 0.10; else if (stalks > 20 && stalks <=30) discount = 0.15; else if (stalks >30)
discount = 0.20;
else
discount = 0.00;
total = stalks * price;
discount_value = discount * total;
payment = total - discount_value;
printf("\n------------------------------------------------------");
printf("\n CUSTOMER BILL ");
printf("\n------------------------------------------------------");
printf("\nFlower : %s", flower);
printf("\nPrice : %.2f", price);
printf("\nStalks : %d", stalks);
printf("\nTotal : %.2f", total);
printf("\nDiscount : %.2f", discount_value);
printf("\nBill : %.2f", payment);
printf("\n\nWould you like to continue? [Press 1 to continue] : ");
scanf("%d", &choice);

}

printf("\n------------------------------------------------------");
printf("\n DAILY SALES REPORT ");
printf("\n------------------------------------------------------");
printf("\nRose : %d stalks", rose);
printf("\nTulip : %d stalks", tulip);
printf("\nLily : %d stalks", lily);
getche();

}

amacam???susah ka senang??bole pecah kepala nk buat nie....kalo masa taip coding tue,kalo tertinggal titik ke,koma ke,program tu x boleh run tau...haaa....jadi,markah pun kureng laaa...

No comments:

Post a Comment