# include
# define which 2.05
# define BEET 1.15
# define have 1.09
Int main ()
{
Bool feel=true;
char ch;
Double art_num=0.0;
Double beet_num=0.0;
Double carrot_num=0.0;
Double total_price;
Double total_weight;
Double packing_freight;
Int discount=0;
While (feel)
{
Double count=0.0;
Printf (" please input you want to order items, order code a (artichoke), b (sugar beet), c (carrot), q (exit) \ n ");
The scanf (" c "\ n %, & amp; Ch);
The switch (ch)
{
Case 'a' :
Printf (" you need to how many pounds of artichokes?" );
Lf the scanf (" % ", & amp; The count);
Art_num +=count;
break;
Case 'b' :
Printf (" how many pounds of sugar beet you need?" );
Lf the scanf (" % ", & amp; The count);
Beet_num +=count;
break;
Case 'c' :
Printf (" how many pounds you need carrots?" );
Lf the scanf (" % ", & amp; The count);
Carrot_num +=count;
break;
Case 'q:
Feel=false;
break;
}
}
Total_price=art_num + BEET + carrot_num beet_num * * * which have;
Total_weight=art_num + beet_num + carrot_num;
If (total_price & gt;=100.0)
{
Discount=(int) total_price/100.0 * 5;
(total_price total_price=total_price total_price/100 * * 0.05);
}
If (total_weight & gt; 0.1 & amp; & Total_weight & lt; 5.0)
{
Packing_freight=6.5;
}
Else if (total_weight & gt; 5.0 & amp; & Total_weight & lt; 20.0)
{
Packing_freight=14.0;
}
The else
{
Packing_freight + (total_weight - 20.0) * 0.5=14.0;
}
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" the artichokes: % 20.2 lf pounds \ t cost: 15.2 lf $% \ n ", art_num, art_num * which);
Printf (" lf 20.2 pounds of sugar BEET: % \ t cost: 15.2 lf $% \ n ", beet_num, beet_num * BEET);
Printf (" carrots: % 18.2 lf pounds \ t cost: 15.2 lf $% \ n ", carrot_num, carrot_num * have);
The packaging and shipping: printf (" % 14.2 lf $\ t discount: % d % % \ n ", packing_freight, discount).
Printf (" the goods total price: 20.2 lf $\ % t cargo gross weight: 9.2 lf % \ n ", total_price, total_weight);
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
return 0;
}
CodePudding user response:
# include
# include
# define which 2.05
# define BEET 1.15
# define have 1.09
Int main ()
{
Bool feel=true;
char ch;
Double art_num=0.0;
Double beet_num=0.0;
Double carrot_num=0.0;
Double total_price;
Double total_weight;
Double packing_freight;
Int discount=0;
While (feel)
{
Double count=0.0;
Printf (" please input you want to order items, order code a (artichoke), b (sugar beet), c (carrot), q (exit) \ n ");
//the scanf (" c "\ n %, & amp; Ch);
The scanf (" % c ", & amp; Ch);
The switch (ch)
{
Case 'a' :
Printf (" you need to how many pounds of artichokes?" );
Lf the scanf (" % ", & amp; The count);
Art_num +=count;
break;
Case 'b' :
Printf (" how many pounds of sugar beet you need?" );
Lf the scanf (" % ", & amp; The count);
Beet_num +=count;
break;
Case 'c' :
Printf (" how many pounds you need carrots?" );
Lf the scanf (" % ", & amp; The count);
Carrot_num +=count;
break;
Case 'q:
Feel=false;
break;
}
getchar();
}
Total_price=art_num + BEET + carrot_num beet_num * * * which have;
Total_weight=art_num + beet_num + carrot_num;
If (total_price & gt;=100.0)
{
Discount=(int) total_price/100.0 * 5;
(total_price total_price=total_price total_price/100 * * 0.05);
}
If (total_weight & gt; 0.1 & amp; & Total_weight & lt; 5.0)
{
Packing_freight=6.5;
}
Else if (total_weight & gt; 5.0 & amp; & Total_weight & lt; 20.0)
{
Packing_freight=14.0;
}
The else
{
Packing_freight + (total_weight - 20.0) * 0.5=14.0;
}
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" the artichokes: % 20.2 lf pounds \ t cost: 15.2 lf $% \ n ", art_num, art_num * which);
Printf (" lf 20.2 pounds of sugar BEET: % \ t cost: 15.2 lf $% \ n ", beet_num, beet_num * BEET);
Printf (" carrots: % 18.2 lf pounds \ t cost: 15.2 lf $% \ n ", carrot_num, carrot_num * have);
The packaging and shipping: printf (" % 14.2 lf $\ t discount: % d % % \ n ", packing_freight, discount).
Printf (" the goods total price: 20.2 lf $\ % t cargo gross weight: 9.2 lf % \ n ", total_price, total_weight);
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
return 0;
}
For your reference ~
CodePudding user response:
Making FYICodePudding user response:
Ready to learn C!