hello everybody, i'm doing a course in c and one of our homework assigments was to write a program for a flower shop, and i ran into a weird problem
when the customer is asked to input a shipping distance and weekday for shipping, he needs to write it like so: 15.3 when the number before the "." is the distance and after is the weekday, when 0.3 means pickup on day 3.
now everything works fine besides the 0, when i put 0.3 or 0.7 or whatever with the 0 before the "." nothing happens, and the program simply waits for more input. why is that? thank you for your help.
this is the code:
#include <stdio.h>
int main()
{ char F,S;
int a,b,c,d;
float flowers, shipping, total;
printf("please choose a flower:");
scanf("%c", &F);
switch(F){
case 'D':
flowers=1.35;
break;
case 'R':
flowers=4.30;
break;
case 'T':
flowers=2.75;
break;
case 'P':
flowers=2.75;
break;
case 'B':
flowers=2.75;
break;
case 'C':
flowers=1.95;
break;
case 'G':
flowers=1.95;
break;
case 'F':
flowers=1.15;
break;
case 'O':
flowers=3.50;
break;
case 'A':
flowers=3.50;
break;
default:
printf("ERROR");
return 1;}
printf("please enter quantity of flowers:");
scanf("%d", &a);
if(a>0) flowers=a*flowers;
else {printf("ERROR");
return 1;}
printf("please enter quantity of bouquets:");
scanf("%d", &b);
if(a>(b*12)) flowers=flowers+(b*10);
else {printf("ERROR");
return 1;}
printf("please enter shipping distance and weekday, seperated by '.':");
scanf("%d.%d", &c,&d);
if (c<25) shipping=(c*(float)3/7);
else if (c>=25) shipping=((25*(float)3/7)+((c-25)*(float)2/7));
if (d>=1 && d<=7);
else {printf("ERROR");
return 1;}
if (c>0) printf("would you like an express shipping?");
scanf("\n%c", &S);
if (S=='Y') shipping=(shipping+25);
else if (S=='N') shipping=shipping;
else {printf("ERROR");
return 1;}
printf("receipt:");
printf("\ncost of flowers = %f", flowers);
printf("\ncost of shipping on day %d = %f", d, shipping);
printf("\ntotal cost of flowers + shipping = %f NIS", total=shipping + flowers);
return 0;
}
i can only use switch, and if else functions.