Answer to Question #261066 in C++ for Kim

Question #261066

The cost of a brand new car is P420,000 for GL model and P398,000 for XL model. If a car



phone will be installed, an additional P40,000 will be added to the cost. Moreover, a 15%



discount on the total cost will be given if the buyer pays in full (not installment).



Write a program that would input the car model bought whether with car phone (use code



"W" for car with car phone and "O" for without car phone) and whether it will be paid in full (use



code "F" for full payment and "I" for installment). Program must then output the net cost of the



car.

1
Expert's answer
2021-11-04T03:50:04-0400
#include <iostream>
using namespace std;
int main(){
    float pGL = 420000, pXL = 398000, phone = 40000, net_price;
    char model, with_phone, pay_type;
    cout<<"Input model (G or X): ";
    cin>>model;
    switch(model){
        case 'G': net_price = pGL; break;
        case 'X': net_price = pXL; break;
        default: cout<<"Invalid model\n"; return 0;
    }


    cout<<"With or without phone (W or O): ";
    cin>>with_phone;
    switch(with_phone){
        case 'W': net_price += phone; break;
        case 'O': break;
        default: cout<<"Invalid option\n"; return 0;
    }


    cout<<"Paid in full or installment (F or I): ";
    cin>>pay_type;
    switch(pay_type){
        case 'F': net_price *= 0.85; break;
        case 'I': break;
        default: cout<<"Invalid option\n"; return 0;
    }


    cout<<"\nNet cost of the car: "<<net_price<<endl;
    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
APPROVED BY CLIENTS