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 selection method.
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string name;
  char ps;
  int trt_typ;
  float bd,ad;
  int d;
  cout<<"Enter the name of patient : ";
  getline(cin,name);
  cout<<"Enter the status of patient : \nChild(C) \nAdult(A) \n";
  cin>>ps;
  switch(ps)
  {
    case 'C': cout<<"Enter the type of treatment : \n1.Restoration \n2.Extraction \n3.Scaling \n";
         cin>>trt_typ;
         d=20;
         switch(trt_typ)
         {
           case 1: bd=6.00;
               ad=6.00-(6.00*0.20);
               cout<<"Price before discount = RM6.00";
               cout<<"\nPrice after discount(20%) = RM"<<ad;
               break;
           case 2: bd=15.50;
               ad=15.50-(15.50*0.20);
               cout<<"Price before discount = RM15.50";
               cout<<"\nPrice after discount(20%) = RM"<<ad;
               break;
           case 3: bd=4.00;
               ad=4.00-(4.00*0.20);
               cout<<"Price before discount = RM4.00";
               cout<<"\nPrice after discount(20%) = RM";
               break;
           default:cout<<"Invalid input ";
               return 0;
         }
         break;
    case 'A': cout<<"Enter the type of treatment : \n1.Restoration \n2.Extraction \n3.Scaling \n";
         cin>>trt_typ;
         d=15;
         switch(trt_typ)
         {
           case 1: bd=7.50;
               ad=7.50-(7.50*0.15);
               cout<<"Price before discount = RM7.50";
               cout<<"\nPrice after discount(15%) = RM"<<ad;
               break;
           case 2: bd=18.00;
               ad=18.00-(18.00*0.15);
               cout<<"Price before discount = RM18.00";
               cout<<"\nPrice after discount(15%) = RM"<<ad;
               break;
           case 3: bd=5.00;
               ad=5.00-(5.00*0.15);
               cout<<"Price before discount = RM5.00";
               cout<<"\nPrice after discount(15%) = RM";
               break;
           default:cout<<"Invalid input ";
               return 0;
         }
         break;
    default:cout<<"Invalid input ";
        return 0;
  }
  cout << endl;
  cout << "============ Hasna Dental ============" << endl;
  cout << "Patient:  " << name << " (" << ps
   << ")" <<endl;
  cout << "Treatment: ";
  if (trt_typ == 1) {
    cout << "Restoration" << endl;
  }
  else if (trt_typ == 2) {
    cout << "Extraction" << endl;
  }
  else {
    cout << "Scaling" << endl;
  }
  cout << "Payment:  RM" << setprecision(2) << bd << endl;
  cout << "Discount: " << setprecision(0) << d << "%" << endl;
  cout << "Total:   RM" <<setprecision(2)<< ad << endl;
  cout << "======================================" << endl;
}
Comments
Leave a comment