Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main ()
- {
- char strCommand[] = ""; //User type command to order calendars.
- double dBill = 0.00; // Bill (without discount).
- double iCounter = 0.00; // How many calendars were ordered.
- printf("\nType what kind of calendars you want to order.");
- printf("\nThe options are - Small, Medium, Big and Special.");
- printf("\nIf you order more than 3 calendars - you got 20 percent discount!");
- printf("\nPrices: \nSmall - 2.40 dollars \nMedium - 3.50 dollars \nBig - 6.30 dollars \nSpecial - 12.00 dollars");
- printf("\nType Done! when you are ready to order.\n");
- do
- {
- scanf("%s", &strCommand);
- if (strcmp(strCommand, "Small") == 0)
- {
- printf("Small calendar ordered.\n");
- dBill += 2.40;
- iCounter += 1;
- }
- if(strcmp(strCommand, "Medium") == 0)
- {
- printf("Medium calendar ordered.\n");
- dBill += 3.50;
- iCounter += 1;
- }
- if(strcmp(strCommand, "Big") == 0)
- {
- printf("Big calendar ordered.\n");
- dBill += 6.30;
- iCounter += 1;
- }
- if(strcmp(strCommand, "Special") == 0)
- {
- printf("Special calendar ordered.\n");
- dBill += 12.00;
- iCounter += 1;
- }
- } while (strcmp(strCommand, "Done!") != 0);
- if (iCounter < 4)
- {
- printf("\nYou ordered %.0lf calendars!", iCounter);
- printf("\nYour bill is %.2lf dollars.", dBill);
- }
- else
- {
- dBill = dBill * 0.80;
- printf("\nYou ordered %.0lf calendars! You got 20 percent off!", iCounter);
- printf("\nYour bill is %.2lf dollars.", dBill);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement