Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- float itemCost, total, overall_total, itemAmount, overall_itemAmount;
- int check_out, attempt=0;
- char payment=0;
- printf("Welcome to my Shopper's Haven.\n");
- while(check_out!=1){
- printf("Please enter the cost of your item: ");
- scanf("%f",&itemCost);
- printf("\n");
- printf("How many of this item do you have? ");
- scanf("%f",&itemAmount);
- printf("\n");
- total=total+(itemCost*itemAmount);
- overall_itemAmount = overall_itemAmount + itemAmount;
- printf("%.2f items have been added to your cart.\n",itemAmount);
- printf("Your new total is %.2f \n ",total);
- printf("\n");
- printf("Would you like to continue shopping, or check out? Press 1 to Check Out\n");
- scanf("%d",&check_out);
- }
- printf("I will be happy to check you out.\n");
- printf("Please enter your form of payment. \n");
- //scanf("%c",&payment);
- scanf("\n%c",&payment); // Handling extra new line character from previous scanf
- /*while (attempt<3){
- printf("This is an invalid form of payment. Please use Visa or Master card \n");
- scanf("%c",&payment);
- attempt++;
- if(attempt==3){
- return 0;
- }
- } */
- if(payment== 'V' || payment =='v'){
- printf("Thank you. Your payment has been received. Goodbye.");
- }
- if(payment== 'M' || payment =='m'){
- printf("Thank you. Your payment has been received. Goodbye.");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement