Advertisement
Lisaveta777

Prata chapter 7 exs 11(not working!)

Aug 9th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.27 KB | None | 0 0
  1. //prata exs chapter 7 number 11 - not working!
  2.  
  3. #include <stdio.h>
  4. #include <ctype.h>
  5. #define APRICE  2.05
  6. #define BPRICE 1.15
  7. #define CPRICE 1.09
  8. #define CUTOFF3 29750.0
  9. #define CUTOFF4 24750.0
  10.  
  11.  
  12. int main()
  13. {
  14.  
  15.     char ch;
  16.     float a,b,c,temp;
  17.     a=b=c=0.0;
  18.     ch = getchar();
  19.  
  20.     while( ch !='q')
  21.     {
  22.         //a=b=c=temp = 0.0;//new order can do this  4 lines up
  23.         printf("How much of it do you want?\n");
  24.             scanf("%f",&temp);
  25.         switch(ch)
  26.         {
  27.             case 'a':
  28.                 {
  29.                    a+=temp;
  30.                 }
  31.                 break;
  32.             case 'b':
  33.                 {
  34.                    b+=temp;
  35.                 }
  36.                 break;
  37.             case 'c':
  38.                 {
  39.                     c+=temp;
  40.                 }
  41.                 break;
  42.         }//end of switch()
  43.         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
  44.         //while() from here. ***WHY is that? I started from proper getchar() in while, for some reason it ignores all
  45.         //getchar() except first one!
  46.         //printf("boo\n");
  47.         printf("what are you ordering now? a/b/c/q- quit\n");
  48.         ch = getchar();
  49.     }//end of while
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement