[PROGRAMMING TECHNIQUE] Skill Based Test
A skill base test was given for assessing proficiency of programming language.
//written by Sorhye
//completed in the homeground with sufficient help and a little crazy spirit
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <windows.h>
using namespace std;
int main(){
//initiate variables
ofstream patientInvoice;
int invoiceNo,day,ward;
string patientName;
string patientIc;
double med, reg,con;
//greet user
cout<<"Greetings! Welcome to the Invoice Generator @ Nusajaya Specialist Hospital!"<<endl;
cout<<"Enter Tax Invoice no => ";
cin>>invoiceNo;
// cout<<endl;
cin.ignore();
cout<<"Enter patient name => ";
getline(cin, patientName);//patientName[40];
// cout<<endl;
cin.clear();
cout<<"enter patient IC no => ";
cin>>patientIc;
cout<<endl;
cin.ignore();
cout<<"=== Services and Items Bill ==="<<endl;
cout<<setw(10)<<"a. Enter charge : Medication "<<" "<<"=> RM";
cin>> med;
// cout<<endl;
cout<<setw(10)<<"b. Enter charge : Registration "<<" "<<"=> RM";
cin>> reg;
// cout<<endl;
cout<<setw(10)<<"c. Enter length of stay (day) "<<" "<<"=> ";
cin>> day;
ward = 100*day;
// cout<<endl;
cout<<setw(10)<<"d. Enter charge : Consultancy "<<" "<<"=> RM";
cin>> con;
// cout<<endl;
cout<<"Please refer to generated Tax Incoice receipt."<<endl;
//Inward calculation process (which you dont need to care about.)
//calculate GST
double medGst,regGst,wardGst,conGst;
//medGst = medication*0.06;
regGst = reg*0.06;
wardGst = ward * 0.06;
//conGst = con * 0.06;
//calculate charge
double medCharge, regCharge, wardCharge, conCharge;
//medCharge = med + medGst;
regCharge = reg + regGst;
wardCharge = ward + wardGst;
//conCharge = con + conGst;
//generate Invoice, baby!
//hybrid use of setw() and tabs!
patientInvoice.open("invoice.txt");
cout<<"Generating.";Sleep(500);cout<<".";Sleep(500);cout<<".";Sleep(500);cout<<".";Sleep(500);cout<<".";
patientInvoice<<" "<< "Tax Incoice No.: "<<invoiceNo<<endl;
patientInvoice<<"===== Patient Information ====="<<endl;patientInvoice<<endl;
patientInvoice<<"Name"<<setw(20)<<":"<< patientName<<endl;
patientInvoice<<"IC No."<<setw(18)<<":"<<patientIc<<endl;
patientInvoice<<"Length of stay"<<setw(10)<<":"<<day<<endl;
patientInvoice<<" "<<"Amount(RM)"<<" "<<"GST(RM)"<<" "<<"Charge(RM)"<<endl;
patientInvoice<<"Itemised Bill"<<endl;
patientInvoice<<setprecision(2) << fixed << showpoint <<endl;
patientInvoice<<"a. Medication "<<setw(10)<<right<<med<<" "<<setw(10)<<right<<"Exempt"<<" "<<setw(10)<<right<<med<<endl;
patientInvoice<<"b. Registration "<<" "<<setw(10)<<right<<reg<<" "<<setw(10)<<right<<regGst<<" "<<setw(10)<<right<<regCharge<<endl;
patientInvoice<<"c. ward"<<" "<<setw(10)<<right<<ward<<" "<<setw(10)<<right<<wardGst<<" "<<setw(10)<<right<<wardCharge<<endl;
patientInvoice<<"d. Consultancy"<<" "<<setw(10)<<right<<con<<" "<<setw(10)<<right<<"Inclusive"<<" "<<setw(10)<<right<<con<<endl;
patientInvoice<<" "<<"----------"<<" "<<"----------"<<" "<<"----------"<<" "<<endl;
patientInvoice<<"Total Tax Invoice"<<" "<<setw(10)<<right<<med+reg+ward+con<<" "<<setw(10)<<right<<regGst+wardGst<<" "<<setw(10)<<right<<med+regCharge+wardCharge+con<<endl<<endl;
patientInvoice<<" ========="<<endl;
patientInvoice<<"Total Bill Amount "<<setw(8)<<right<<med+regCharge+wardCharge+con<<endl;
patientInvoice<<" ========="<<endl;
}