Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- float roses = 1.50;
- float sunflower = 1;
- float lilly = 0.50;
- float type;
- float sum;
- float total=0.0;
- int addon=1;
- int stem;
- do{
- printf("Type of flowers\n");
- printf("Press 1 for roses, 2 for sunflower and 3 for lilly:");
- scanf("%f", &type);
- if(type<4 && type>0){
- if(type==1){type=roses;}
- else if(type==2){type=sunflower;}
- else if(type==3){type=lilly;}
- printf("How many stems?:");
- scanf("%d",&stem);
- sum=type*stem;
- printf("%d stem of flower is: RM%.2f\n\n",stem,sum);
- total=(total+sum);
- printf("Do you wanna purchase more?(1 for yes,2 for no):\n\n");
- scanf("%d",&addon);
- }
- }
- while(addon==1);
- printf("Total price of flowers purchased is: RM %.2f\n",total);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment