Answer to Question #185361 in C++ for Shila

Question #185361
Status Restoration (1) Extraction(2) Scaling(3)

Children(C) RM6.00 RM15.50 RM4.00
Adult(A) RM7.50 RM18.00 RM5.00



the discount of 20% will be given for children’s treatment and 15% discount for adult’s treatment. write a c++ program of switch case :

•Reads the patient’s name, patient status, and type of treatment.
•Display the appropriate message when user enter invalid status.
•Calculates payment before and after discount.
•At the end of program, it displays the patient’s name and total payment after discount.
1
Expert's answer
2021-04-25T18:47:03-0400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char nm[30];
    string st;
    int n,status,preference;
    float Discount,payment,Price;
    cout<<"Enter your name ";
    cin>>nm;
    cout<<"\nEnter patient status\n1. Adult\n2. Child\n";
    cin>>status;
    switch(status)
    {
        case 1: st="Adult";
                break;
        case 2: st="Child";
                break;
        default: cout<<"Invalid Status!!!";
    }
    cout<<"\nEnter preferred type of treatment\n1. Restoration\n2. Extraction\n3. Scaling\n";
    cin>>preference;
    switch(preference)
    {
    case 1: if(status==1)
            {
                Price=7.50;
                Discount=7.50*0.15;
                payment=7.50-Discount;
                cout<<"\nPatient Name: "<<nm<<"\nStatus: "<<st<<"\nPrice = RM"<<Price<<"\nDiscout = RM"<<Discount<<"\nTotal Payment = RM"<<payment;
            }
            if(status==2)
            {
                Price=6.00;
                Discount=6.00*0.20;
                payment=6.00-Discount;
                cout<<"\nPatient Name: "<<nm<<"\nStatus: "<<st<<"\nPrice = RM"<<Price<<"\nDiscout = RM"<<Discount<<"\nTotal Payment = RM"<<payment;
            }
            break;
    case 2: if(status==1)
            {
                Price=18.00;
                Discount=18.00*0.15;
                payment=18.00-Discount;
                cout<<"\nPatient Name: "<<nm<<"\nStatus: "<<st<<"\nPrice = RM"<<Price<<"\nDiscout = RM"<<Discount<<"\nTotal Payment = RM"<<payment;
            }
            if(status==2)
            {
                Price=15.50;
                Discount=15.50*0.20;
                payment=15.50-Discount;
                cout<<"\nPatient Name: "<<nm<<"\nStatus: "<<st<<"\nPrice = RM"<<Price<<"\nDiscout = RM"<<Discount<<"\nTotal Payment = RM"<<payment;
            }
            break;
    case 3: if(status==1)
            {
                Price=5.00;
                Discount=5.00*0.15;
                payment=5.00-Discount;
                cout<<"\nPatient Name: "<<nm<<"\nStatus: "<<st<<"\nPrice = RM"<<Price<<"\nDiscout = RM"<<Discount<<"\nTotal Payment = RM"<<payment;
            }
            if(status==2)
            {
                Price=4.00;
                Discount=4.00*0.20;
                payment=4.00-Discount;
                cout<<"\nPatient Name: "<<nm<<"\nStatus: "<<st<<"\nPrice = RM"<<Price<<"\nDiscout = RM"<<Discount<<"\nTotal Payment = RM"<<payment;
            }
            break;
    default: cout<<"Invalid Input!!!";
    }
}

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