Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <conio.h>
- #define a 1000
- #define b 800
- #define c 1000
- #define d 600
- #define e 2000
- #define f 3000
- int main()
- {
- char choice, answer, cont_prog, confirm,n;
- float order, price, card, name;
- do
- {
- printf("Menu\n");
- printf("Products available for sale.\n");
- printf("1. iPhone 7 $1000\n");
- printf("2. iPhone 6 $800\n");
- printf("3. iPad Pro $1000\n");
- printf("4. Apple Watch $600\n");
- printf("5. Macbook Pro $2000\n");
- printf("6. iMac $3000\n");
- printf("7. Quit\n");
- printf("Enter choice: ");
- scanf(" %c", &choice);
- choice = toupper(choice);
- switch( choice )
- {
- case '1' : printf("How many would you like to buy? \n");
- scanf("%f", &order);
- printf("Please enter your name\n");
- scanf("%f", &name);
- printf("Please enter your credit card number\n");
- scanf("%f", &card);
- if(card < 1000000000000 || card > 10000000000000000)
- {
- printf("INVALID\n");
- }
- if(card < 100000000000000 && card > 9999999999999)
- {
- printf("INVALID\n");
- }
- price = order * a;
- printf("Name: %c\n",n);
- printf("Credit card number: %f\n");
- printf("You will have to pay %f\n", price);
- printf("Please confirm your order. Y/N\n");
- scanf(" %c", &confirm);
- confirm = toupper(confirm);
- if ( confirm == 'Y')
- {
- printf("Thank you for purchasing!\n");
- }
- else if ( confirm == 'N' )
- {
- printf("Your order has been cancelled.\n");
- }
- else
- {
- printf("Invalid input!\n");
- }
- break;
- case '2' : printf("How many would you like to buy? \n");
- scanf("%f", &order);
- printf("Please enter your name\n");
- scanf("%f", &name);
- printf("Please enter your credit card number\n");
- scanf("%f", &card);
- if(card < 1000000000000 || card > 10000000000000000)
- {
- printf("INVALID\n");
- }
- if(card < 100000000000000 && card > 9999999999999)
- {
- printf("INVALID\n");
- }
- price = order * b;
- printf("Name: %c\n",n);
- printf("Credit card number: %f\n");
- printf("You will have to pay %f\n", price);
- printf("Please confirm your order. Y/N\n");
- scanf(" %c", &confirm);
- confirm = toupper(confirm);
- if ( confirm == 'Y')
- {
- printf("Thank you for purchasing!\n");
- }
- else if ( confirm == 'N' )
- {
- printf("Your order has been cancelled.\n");
- }
- else
- {
- printf("Invalid input!\n");
- }
- break;
- case '3' : printf("How many would you like to buy? \n");
- scanf("%f", &order);
- printf("Please enter your name\n");
- scanf("%f", &name);
- printf("Please enter your credit card number\n");
- scanf("%f", &card);
- if(card < 1000000000000 || card > 10000000000000000)
- {
- printf("INVALID\n");
- }
- if(card < 100000000000000 && card > 9999999999999)
- {
- printf("INVALID\n");
- }
- price = order * c;
- printf("Name: %c\n",n);
- printf("Credit card number: %f\n");
- printf("You will have to pay %f\n", price);
- printf("Please confirm your order. Y/N\n");
- scanf(" %c", &confirm);
- confirm = toupper(confirm);
- if ( confirm == 'Y')
- {
- printf("Thank you for purchasing!\n");
- }
- else if ( confirm == 'N' )
- {
- printf("Your order has been cancelled.\n");
- }
- else
- {
- printf("Invalid input!\n");
- }
- break;
- case '4' : printf("How many would you like to buy? \n");
- scanf("%f", &order);
- printf("Please enter your name\n");
- scanf("%f", &name);
- printf("Please enter your credit card number\n");
- scanf("%f", &card);
- if(card < 1000000000000 || card > 10000000000000000)
- {
- printf("INVALID\n");
- }
- if(card < 100000000000000 && card > 9999999999999)
- {
- printf("INVALID\n");
- }
- price = order * d;
- printf("Name: %c\n",n);
- printf("Credit card number: %f\n");
- printf("You will have to pay %f\n", price);
- printf("Please confirm your order. Y/N\n");
- scanf(" %c", &confirm);
- confirm = toupper(confirm);
- if ( confirm == 'Y')
- {
- printf("Thank you for purchasing!\n");
- }
- else if ( confirm == 'N' )
- {
- printf("Your order has been cancelled.\n");
- }
- else
- {
- printf("Invalid input!\n");
- }
- break;
- case '5' : printf("How many would you like to buy? \n");
- scanf("%f", &order);
- printf("Please enter your name\n");
- scanf("%f", &name);
- printf("Please enter your credit card number\n");
- scanf("%f", &card);
- if(card < 1000000000000 || card > 10000000000000000)
- {
- printf("INVALID\n");
- }
- if(card < 100000000000000 && card > 9999999999999)
- {
- printf("INVALID\n");
- }
- price = order * e;
- printf("Name: %c\n",n);
- printf("Credit card number: %f\n");
- printf("You will have to pay %f\n", price);
- printf("Please confirm your order. Y/N\n");
- scanf(" %c", &confirm);
- confirm = toupper(confirm);
- if ( confirm == 'Y')
- {
- printf("Thank you for purchasing!\n");
- }
- else if ( confirm == 'N' )
- {
- printf("Your order has been cancelled.\n");
- }
- else
- {
- printf("Invalid input!\n");
- }
- break;
- case '6' : printf("How many would you like to buy? \n");
- scanf("%f", &order);
- printf("Please enter your name\n");
- scanf("%f", &name);
- printf("Please enter your credit card number\n");
- scanf("%f", &card);
- if(card < 1000000000000 || card > 10000000000000000)
- {
- printf("INVALID\n");
- }
- if(card < 100000000000000 && card > 9999999999999)
- {
- printf("INVALID\n");
- }
- price = order * f;
- printf("Name: %c\n",n);
- printf("Credit card number: %f\n");
- printf("You will have to pay %f\n", price);
- printf("Please confirm your order. Y/N\n");
- scanf(" %c", &confirm);
- confirm = toupper(confirm);
- if ( confirm == 'Y')
- {
- printf("Thank you for purchasing!\n");
- }
- else if ( confirm == 'N' )
- {
- printf("Your order has been cancelled.\n");
- }
- else
- {
- printf("Invalid input!\n");
- }break;
- case '7' : printf("Bye!\n");
- break;
- default : printf("Invalid input!\n");
- }
- printf("Do you want to start again? (y/n): ");
- cont_prog = getchar();
- } while (cont_prog == 'y' || cont_prog == 'Y');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement