Thanks for the help I've my final code ready for tomorrows class
Code:
#include<stdio.h>
int main(void)
{
char instruc[2];
const double artichokes=1.25,beets=0.65,carrots=0.89;
double totalartichokes=0,totalbeets=0,totalcarrots=0,totalpound=0,shipping=0,input=0,totalcost=0,pounds=0,subtotalcost=0,discount=0;
bool keepgoing =true;// a bolean data type
printf("\n");
printf("\n");
printf(" ABC Mail Order Grocery\n\n");
printf(" Type 'a' for artichokes, 'b' for beets, 'c' for carrots , 't' to total sale ,\n and 'q' to exit sale.\n\n");
//frist we need an infinite loop
while (1){// 1 is always logicaly true
//next we will read an instruction from stdio
scanf("%s %lf",instruc, &input);
switch(instruc[0])
{
case 'a':
pounds+=input;
totalartichokes=artichokes*input;
printf(" Artichokes %.2lf\n", totalartichokes);
break;
case 'b':
pounds+=input;
totalbeets=beets * input;
printf(" beets %.2lf\n", totalbeets);
break;
case 'c':
pounds+=input;
totalcarrots=carrots * input;
printf(" carrots %.2lf\n", totalcarrots);
break;
{ case 'q': {keepgoing = false;break; } }//end of exiting if statement
case 't':
subtotalcost= totalartichokes+totalbeets+totalcarrots ;
totalpound+=pounds;
printf("\n SubTotal is $%.2lf \n",subtotalcost);
{ if (subtotalcost>= 100) {
totalcost = subtotalcost - .05 * subtotalcost ;
discount = .05 * subtotalcost ;
printf(" Discount is $%.2lf\n",discount);
printf("\n Total is $%.2lf \n",totalcost); } }//end of discount if statement
{if(totalpound <=5) {
totalcost=3.50+totalcost;// $3.50 shipping
shipping=3.50;
printf("\n Total Weight is %.2lf\n",totalpound);
printf(" Shipping and handling is $%.2lf\n",shipping);
printf("\n Total is $%.2lf \n",totalcost);
break; }
if(totalpound <= 20){
totalcost=10.00+totalcost;// $10.00 over 5pounds ,but under 20pounds shipping
shipping=10.00;
printf("\n Total Weight is %.2lf\n",totalpound);
printf(" Shipping and handling is $%.2lf\n",shipping);
printf("\n Total is $%.2lf \n",totalcost);break; }
if (totalpound >20) {
totalcost=8.00+.10*totalpound+totalcost;
shipping=8.00+(.10*totalpound);
printf("\n Total Weight is %.2lf\n",totalpound);
printf(" Shipping and handling is $%.2lf\n",shipping);
printf("\n Total is $%.2lf \n",totalcost);break; } }//end of shipping if statement
}// end switch(instruc[0])
if (keepgoing==false)break; // exit the infinite loop
}//end while (1) loop
}//end main
here my program is running
Attachment 6854