Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Задача 18 Довършете задачата за кемперите от миналия път като добавите
- променлива, в която да се събират парите, които клиентът дължи на компанията.
- Принтирайте резултата. Питайте клиента дали иска още налични продукти.*/
- #include <stdio.h>
- int main() {
- const float caravan = 3;
- const float camper = 3;
- const float pricePerDayForThreeCaravans = 90;
- const float pricePerDayForThreeCampers = 100;
- float camperOrCaravan = 0;
- float holidayDays = 0;
- float fTotalSumForPayChoiceOne = 0;
- float fTotalSumForPayChoiceTwo = 0;
- int iSmthElseCamper = 0;
- int iSmthElseCaravan = 0;
- int iExtraCaravan = 0;
- int iExtraCamper = 0;
- double fExtraSumForCaravan = 0;
- double fExtraSumForCamper = 0;
- printf("Hello mr/ms, What would you like a camper or caravan? For camper press 1, for caravan press 2! :");
- scanf("%f", &camperOrCaravan);
- if (camperOrCaravan == 1){ // camper
- printf("\nGood choice! Now how many days would you like for your vacation: ");
- scanf("%f", &holidayDays);
- fTotalSumForPayChoiceOne = (pricePerDayForThreeCampers / camper) * holidayDays;
- printf("\nYour total amount for pay is: %.2fBGN", fTotalSumForPayChoiceOne);
- printf("\nDo you want smth else? For YES press 1 for NO press 0:");
- scanf("%d", &iSmthElseCamper);
- if (iSmthElseCamper == 1){
- printf("\nWe have a caravan would you like? For YES press 1 for NO press 0: ");
- scanf("%d", &iExtraCaravan);}
- if (iExtraCaravan == 1){
- fExtraSumForCaravan = (pricePerDayForThreeCaravans * holidayDays) / caravan;
- fExtraSumForCaravan = fExtraSumForCaravan + fTotalSumForPayChoiceOne; // fExtraSumForCaravan += fTotalSumForPayChoiceOne
- printf("\nYour total amount is: %.2f BGN", fExtraSumForCaravan);
- }
- else if (iExtraCaravan == 0 || iSmthElseCamper == 0 ){
- printf("Thanks for the order we will see you soon, your bill is : %.2f BGN",fTotalSumForPayChoiceOne);
- }
- }
- if (camperOrCaravan == 2){ // caravan
- printf("\nGood choice! Now how many days would you like for your vacation: ");
- scanf("%f", &holidayDays);
- fTotalSumForPayChoiceTwo = (pricePerDayForThreeCaravans / caravan) * holidayDays;
- printf("Your total amount for pay is: %.2fBGN", fTotalSumForPayChoiceTwo);
- printf("\nDo you want smth else? For YES press 1 for NO press 0: ");
- scanf("%d", &iSmthElseCaravan);
- if (iSmthElseCaravan == 1){
- printf("\nWe have a camper would you like? For YES press 1 for NO press 0: ");
- scanf("%d", &iExtraCamper);
- }
- if ( iExtraCamper == 1){
- fExtraSumForCamper = (pricePerDayForThreeCampers * holidayDays) / camper;
- fExtraSumForCamper = fExtraSumForCamper + fTotalSumForPayChoiceTwo; //fExtraSumForCamper += fTotalSumForPayChoiceTwo
- printf("\nYour total amount is: %.2f BGN", fExtraSumForCamper);
- }
- else if (iExtraCamper == 0 || iSmthElseCaravan == 0){
- printf("Thanks for the order we will see you soon, your bill is: %.2f", fTotalSumForPayChoiceTwo);
- }
- else if (camperOrCaravan > 2 || camperOrCaravan < 1) {
- printf("Invalid choice");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement