#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
//define
char choice,a,b,c,exit;
float numa,numb,numc,suma=0,sumb=0,sumc=0,totalsum;
float moneya,moneyb,moneyc,money,charge,totalcost,grandtotal;
//shopping
do{
printf("Please input your choice:\n");
printf("a for artichokes,b for beets ,c for carrots\n");
scanf("\n%c",&choice);
switch (choice){
case 'a':
printf("please input how many pounds you want for artichokes:\n");
scanf("%f",&numa);
suma=suma+numa;
printf("you have bought %5.2f pounds artichokes\n",suma);
case 'b':
printf("please input how many pounds you want for beets:\n");
scanf("%f",&numb);
sumb=sumb+numb;
printf("you have bought %5.2f pounds beets\n",sumb);
case 'c':
printf("please input how many pounds you want for carrots:\n");
scanf("%f",&numc);
sumc=sumc+numc;
printf("you have bought %5.2f pounds carrots\n",sumc);
printf("If you want to exit shopping please input q\n");
scanf("\n%c",&exit);
}
}while(exit!='q');
moneya=suma*2.05;
moneyb=sumb*1.15;
moneyc=sumc*1.09;
totalsum=suma+sumb+sumc;
//dicount
money=suma*2.05+sumb*1.15+sumc*1.09;
//the cost per pound
printf("artichokes $2.05per pound,beets $1.15per pound,carrots $1.09 per pound\n");
//the pounds ordered
printf("you ordered %5.2f pounds artichokes\n",suma);
printf("you ordered %5.2f pounds beets\n",sumb);
printf("you ordered %5.2f pounds carrots\n",sumc);
if(money<100&&totalsum<=5){
totalcost=moneya+moneyb+moneyc;
charge=6.50;
grandtotal=totalcost+charge;
printf("the cost for artichokes=$%5.2f\n",moneya);
printf("the cost for beets=$%5.2f\n",moneyb);
printf("the cost for carrots=$%5.2f\n",moneyc);
}
else if(money<100&&totalsum>5&&totalsum<20){
totalcost=moneya+moneyb+moneyc;
charge=14.00;
grandtotal=totalcost+charge;
printf("the cost for artichokes=$%5.2f\n",moneya);
printf("the cost for beets=$%5.2f\n",moneyb);
printf("the cost for carrots=$%5.2f\n",moneyc);
}
else if(money<100&&totalsum>=20){
totalcost=moneya+moneyb+moneyc;
charge=14.00+0.5*totalsum;
grandtotal=totalcost+charge;
printf("the cost for artichokes=$%5.2f\n",moneya*0.95);
printf("the cost for beets=$%5.2f\n",moneyb*0.95);
printf("the cost for carrots=$%5.2f\n",moneyc*0.95);
}
if(money>=100&&totalsum<=5){
totalcost=(moneya+moneyb+moneyc)*0.95;
charge=6.50;
grandtotal=totalcost+charge;
printf("the dicount is 0.95\n");
printf("the cost for artichokes=$%5.2f\n",moneya*0.95);
printf("the cost for beets=$%5.2f\n",moneyb*0.95);
printf("the cost for carrots=$%5.2f\n",moneyc*0.95);
}
else if(money>=100&&totalsum>5&&totalsum<20){
totalcost=(moneya+moneyb+moneyc)*0.95;
charge=14.00;
grandtotal=totalcost+charge;
printf("the dicount is 0.95\n");
printf("the cost for artichokes=$%5.2f\n",moneya*0.95);
printf("the cost for beets=$%5.2f\n",moneyb*0.95);
printf("the cost for carrots=$%5.2f\n",moneyc*0.95);
}
else if(money>=100&&totalsum>=20){
totalcost=(moneya+moneyb+moneyc)*0.95;
charge=14.00+0.5*totalsum;
grandtotal=totalcost+charge;
printf("the dicount is 0.95\n");
printf("the cost for artichokes=$%5.2f\n",moneya*0.95);
printf("the cost for beets=$%5.2f\n",moneyb*0.95);
printf("the cost for carrots=$%5.2f\n",moneyc*0.95);
}
printf("the total cost of the order is $%5.2f\n",totalcost);
printf("the shipping charge is $%5.2f\n",charge);
printf("the grand total of all the charges is $%5.2f\n",grandtotal);
system("pause");
return 0;
}