donmike25

inlab(6)2013

Jul 9th, 2013
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.    
  6.     float roses = 1.50;
  7.     float sunflower = 1;
  8.     float lilly = 0.50;
  9.     float type;
  10.     float sum;
  11.     float total=0.0;
  12.     int addon=1;
  13.     int stem;
  14.  
  15. do{
  16.     printf("Type of flowers\n");
  17.     printf("Press 1 for roses, 2 for sunflower and 3 for lilly:");
  18.     scanf("%f", &type);
  19.     if(type<4 && type>0){
  20.         if(type==1){type=roses;}
  21.         else if(type==2){type=sunflower;}
  22.         else if(type==3){type=lilly;}
  23.     printf("How many stems?:");
  24.     scanf("%d",&stem);
  25.     sum=type*stem;
  26.     printf("%d stem of flower is: RM%.2f\n\n",stem,sum);
  27.  
  28.     total=(total+sum);
  29.    
  30.     printf("Do you wanna purchase more?(1 for yes,2 for no):\n\n");
  31.     scanf("%d",&addon);
  32. }      
  33. }
  34.  
  35. while(addon==1);
  36.  
  37. printf("Total price of flowers purchased is: RM %.2f\n",total);
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment