Answer to Question #193828 in C++ for lee

Question #193828

Husna Dental is a personal dental clinic that recently operated on 1st January 2015. The payment for dentistry services at Husna Dental is different based on the type of treatment and patient status.


 Patient Status

Restoration (1)

Extraction(2)

Scaling(3)

Children(C)

RM6.00

RM15.50

RM4.00

Adult(A)

RM7.50

RM18.00

RM5.00

   

       Due to the opening ceremony, the discount of 20% will be given for children’s treatment and 15% discount for adult’s treatment.

Write a C++ program that performs the following.

· · · ·

a) Reads the patient's name, patient status, and type of treatment.


b) Displays the appropriate message when the user enters an invalid status.


c) Calculates the payment before and after discount.


At the end of the program, displays receipt that contain patient’s name and her/his total payment after discount.


write in switch case method.




1
Expert's answer
2021-05-15T17:08:08-0400


#include <iostream>


using namespace std;


int main()
{
    /*
    Reads the patient's name, patient status, and type of treatment.
    */
    char status;
    string name;
    int type_of_treatment;
    cout<<"\nEnter the name of the patient: ";
    cin>>name;
    cout<<"\nEnter the status of the patient: ";
    cin>>status;
    cout<<"\nEnter the type of treatment: ";
    cin>>type_of_treatment;
    double balance;
    
    if (status=='C' ||status=='A'){
        //c) Calculates the payment before and after discount.
        //before
        char ch;
        switch(ch){
            case 'C':
                int ch2;
                switch(ch2){
                    case 1:
                        balance=6.00*1.2;
                        break;
                    case 2:
                        balance=15.00*1.2;
                        break;
                    case 3:
                        balance=4.00*1.2;
                        break;
                    
                }
                break;
            case 'A':
                int ch3;
                switch(ch3){
                    case 1:
                        balance=6.00*1.15;
                        break;
                    case 2:
                        balance=15.00*1.15;
                        break;
                    case 3:
                        balance=4.00*1.15;
                        break;
                    
                }
                break;
            default:
                break;
        }
        //after discount
        char ch4;
        switch(ch4){
            case 'C':
                int ch2;
                switch(ch2){
                    case 1:
                        balance=6.00*0.8;
                        break;
                    case 2:
                        balance=15.00*0.8;
                        break;
                    case 3:
                        balance=4.00*0.8;
                        break;
                    
                }
                break;
            case 'A':
                int ch3;
                switch(ch3){
                    case 1:
                        balance=6.00*0.85;
                        break;
                    case 2:
                        balance=15.00*0.85;
                        break;
                    case 3:
                        balance=4.00*0.85;
                        break;
                    
                }
                break;
            default:
                break;
        }
        cout<<"Name: "<<name<<" balance: "<<balance;
    }
    //b) Displays the appropriate message when the user enters an invalid status.
    else{
        cout<<"You entered invalid status";
    }
    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