Advertisement
HristoBaychev

extRest

Oct 6th, 2021
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.55 KB | None | 0 0
  1. /*Задача 18 Довършете задачата за кемперите от миналия път като добавите
  2. променлива, в която да се събират парите, които клиентът дължи на компанията.
  3. Принтирайте резултата. Питайте клиента дали иска още налични продукти.*/
  4.  
  5. #include <stdio.h>
  6.  
  7.  int main() {
  8.     const float caravan = 3;
  9.     const float camper = 3;
  10.     const float pricePerDayForThreeCaravans = 90;
  11.     const float pricePerDayForThreeCampers = 100;
  12.      
  13.     float camperOrCaravan = 0;
  14.     float holidayDays = 0;
  15.     float fTotalSumForPayChoiceOne = 0;
  16.     float fTotalSumForPayChoiceTwo = 0;    
  17.        
  18.     int iSmthElseCamper = 0;
  19.     int iSmthElseCaravan = 0;
  20.     int iExtraCaravan = 0;
  21.     int iExtraCamper = 0;
  22.        
  23.     double fExtraSumForCaravan = 0;
  24.     double fExtraSumForCamper = 0;
  25.  
  26.      printf("Hello mr/ms, What would you like a camper or caravan? For camper press 1, for caravan press 2! :");
  27.      scanf("%f", &camperOrCaravan);
  28.      
  29.      if (camperOrCaravan == 1){ // camper
  30.      printf("\nGood choice! Now how many days would you like for your vacation: ");
  31.      scanf("%f", &holidayDays);
  32.          fTotalSumForPayChoiceOne = (pricePerDayForThreeCampers  / camper) * holidayDays;
  33.          printf("\nYour total amount for pay is: %.2fBGN", fTotalSumForPayChoiceOne);
  34.          printf("\nDo you want smth else? For YES press 1 for NO press 0:");
  35.          scanf("%d", &iSmthElseCamper);
  36.          if (iSmthElseCamper == 1){
  37.             printf("\nWe have a caravan would you like? For YES press 1 for NO press 0: ");
  38.             scanf("%d", &iExtraCaravan);}
  39.             if (iExtraCaravan == 1){
  40.             fExtraSumForCaravan = (pricePerDayForThreeCaravans * holidayDays) / caravan;
  41.             fExtraSumForCaravan = fExtraSumForCaravan + fTotalSumForPayChoiceOne;  // fExtraSumForCaravan += fTotalSumForPayChoiceOne
  42.             printf("\nYour total amount is: %.2f BGN", fExtraSumForCaravan);
  43.             }
  44.             else if (iExtraCaravan == 0 || iSmthElseCamper == 0 ){
  45.             printf("Thanks for the order we will see you soon, your bill is : %.2f BGN",fTotalSumForPayChoiceOne);
  46.             }
  47.      }
  48.     if (camperOrCaravan == 2){ // caravan
  49.     printf("\nGood choice! Now how many days would you like for your vacation: ");
  50.     scanf("%f", &holidayDays);
  51.          fTotalSumForPayChoiceTwo = (pricePerDayForThreeCaravans / caravan) * holidayDays;
  52.          printf("Your total amount for pay is: %.2fBGN", fTotalSumForPayChoiceTwo);
  53.          printf("\nDo you want smth else? For YES press 1 for NO press 0: ");
  54.          scanf("%d", &iSmthElseCaravan);
  55.          if (iSmthElseCaravan == 1){
  56.             printf("\nWe have a camper would you like? For YES press 1 for NO press 0: ");
  57.             scanf("%d", &iExtraCamper);
  58.             }
  59.             if ( iExtraCamper == 1){
  60.             fExtraSumForCamper = (pricePerDayForThreeCampers * holidayDays) / camper;
  61.             fExtraSumForCamper = fExtraSumForCamper + fTotalSumForPayChoiceTwo; //fExtraSumForCamper += fTotalSumForPayChoiceTwo
  62.             printf("\nYour total amount is: %.2f BGN", fExtraSumForCamper);
  63.             }
  64.             else if (iExtraCamper == 0 || iSmthElseCaravan == 0){
  65.              printf("Thanks for the order we will see you soon, your bill is: %.2f", fTotalSumForPayChoiceTwo);
  66.             }
  67.     else if (camperOrCaravan > 2 || camperOrCaravan < 1)   {
  68.     printf("Invalid choice");
  69.     }
  70.    }
  71.    return 0;
  72.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement