Advertisement
Vereekeld

Untitled

Feb 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     float itemCost, total, overall_total, itemAmount, overall_itemAmount;
  6.     int check_out, attempt=0;
  7.     char payment=0;
  8.  
  9.     printf("Welcome to my Shopper's Haven.\n");
  10.  
  11.     while(check_out!=1){
  12.  
  13.         printf("Please enter the cost of your item: ");
  14.         scanf("%f",&itemCost);
  15.         printf("\n");
  16.         printf("How many of this item do you have? ");
  17.         scanf("%f",&itemAmount);
  18.         printf("\n");
  19.  
  20.         total=total+(itemCost*itemAmount);
  21.         overall_itemAmount = overall_itemAmount + itemAmount;
  22.  
  23.         printf("%.2f items have been added to your cart.\n",itemAmount);
  24.         printf("Your new total is %.2f \n ",total);
  25.  
  26.         printf("\n");
  27.         printf("Would you like to continue shopping, or check out? Press 1 to Check Out\n");
  28.         scanf("%d",&check_out);
  29.     }
  30.             printf("I will be happy to check you out.\n");
  31.             printf("Please enter your form of payment. \n");
  32.             //scanf("%c",&payment);
  33.             scanf("\n%c",&payment); // Handling extra new line character from previous scanf
  34.  
  35.             /*while (attempt<3){
  36.                 printf("This is an invalid form of payment. Please use Visa or Master card \n");
  37.                 scanf("%c",&payment);
  38.                 attempt++;
  39.                 if(attempt==3){
  40.                    
  41.                     return 0;
  42.                 }
  43.             } */
  44.             if(payment== 'V' || payment =='v'){
  45.                 printf("Thank you. Your payment has been received. Goodbye.");
  46.             }
  47.             if(payment== 'M' || payment =='m'){
  48.                 printf("Thank you. Your payment has been received. Goodbye.");
  49.             }
  50.  
  51.  
  52.             return 0;
  53.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement