Answer to Question #256946 in C for Jack

Question #256946
The airline tickets are most expensive if you are purchasing on the same day and least expensive if purchased earlier. If a ticket is reserved 7 days before the flight then it charges no extra amount, on the 6th day the price is incremented by 10%, on the 5th day 15%, on the 4th day 17%, on the 3rd day 20%, on the 2nd day by 15% and on the final day it is double the original price. Write a program that asks the user the current date and city from which the user will take the flight and the city to which he is traveling as well as the date of flight. Provided the following prices calculate the amount user has to pay. From To Amount Lahore ‘L’ Karachi ‘K’ 13,940 Islamabad ‘I’ Karachi ‘I’ 13, 940 Islamabad ‘I’ Lahore ‘L’ 32,500 Islamabad ‘I’ Gilgit ‘G’ 25,850
1
Expert's answer
2021-10-27T00:47:47-0400


#include <iostream>


using namespace std;


int main()
{
    int price;
    cout<<"\nEnter initial price: ";
    cin>>price;
    int days;
    cout<<"\nEnter the difference between the booking day and the flight day: ";
    cin>>days;
    
    switch(days){
        case 7:
            price=price;
            break;
        case 6:
            price=price*1.1;
            break;
        case 5:
            price=price*1.15;
            break;
        case 4:
            price=price*1.17;
            break;
        case 3:
            price=price*1.2;
            break;
        case 2:
            price=price*1.15;
            break;
        case 1:
            price=price*2;
            break;
    }
    cout<<"\nThe final price = "<<price;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS