Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //prata exs chapter 7 number 11 - not working!
- #include <stdio.h>
- #include <ctype.h>
- #define APRICE 2.05
- #define BPRICE 1.15
- #define CPRICE 1.09
- #define CUTOFF3 29750.0
- #define CUTOFF4 24750.0
- int main()
- {
- char ch;
- float a,b,c,temp;
- a=b=c=0.0;
- ch = getchar();
- while( ch !='q')
- {
- //a=b=c=temp = 0.0;//new order can do this 4 lines up
- printf("How much of it do you want?\n");
- scanf("%f",&temp);
- switch(ch)
- {
- case 'a':
- {
- a+=temp;
- }
- break;
- case 'b':
- {
- b+=temp;
- }
- break;
- case 'c':
- {
- c+=temp;
- }
- break;
- }//end of switch()
- printf("so its' %f of a, %f of b, %f of c\n",a,b,c);//for some reason it goes straight to the top of
- //while() from here. ***WHY is that? I started from proper getchar() in while, for some reason it ignores all
- //getchar() except first one!
- //printf("boo\n");
- printf("what are you ordering now? a/b/c/q- quit\n");
- ch = getchar();
- }//end of while
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement