Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <iomanip>
- using namespace std;
- void userInformation(string&, char&, char&);
- void charge(char, char, double&, double&);
- void receipt(string, char, char, double, double);
- int main(){
- bool stop = false;
- string smartCard;
- char packageCode, additionalTV, stopResult;
- double totalBeforeTax, totalWithTax, totalFamilyPack = 0.0, totalFamilyHDPack = 0.0;
- while(stop != true){
- userInformation(smartCard, packageCode, additionalTV);
- charge(packageCode, additionalTV, totalBeforeTax, totalWithTax);
- receipt(smartCard, packageCode, additionalTV, totalBeforeTax, totalWithTax);
- if(packageCode == 'A' || packageCode == 'a')
- totalFamilyPack += totalWithTax;
- if(packageCode == 'B' || packageCode == 'b')
- totalFamilyHDPack += totalWithTax;
- cout << "\nEnter N to stop or another key to continue : ";
- cin >> stopResult;
- cout << endl;
- if(stopResult == 'N' || stopResult == 'n')
- stop = true;
- else
- stop = false;
- }
- cout << "----------------------------------------------------------------\n";
- cout << "Total Package Collection\n";
- cout << "Astro Family Pack (RM) : " << totalFamilyPack ;
- cout << "\nAstro Family HD Pack (RM) : " << totalFamilyHDPack;
- cout << "\n----------------------------------------------------------------\n";
- }
- void userInformation(string &smartCard, char &packageCode, char &additionalTV){
- cout << "Enter your smart card number : " ;
- cin >> smartCard;
- cout << "Enter package code : ";
- cin >> packageCode;
- if(packageCode != 'A' && packageCode != 'B'){
- cout << "You have entered invalid package code";
- } else {
- cout << "Enter additional TV series code : ";
- cin >> additionalTV;
- }
- }
- void charge(char packageCode, char additionalTV, double &totalBeforeTax, double &totalWithTax){
- float packagePrice, additionalPrice = 0;
- if(packageCode == 'A' || packageCode == 'a'){
- packagePrice = 130.00;
- if(additionalTV == 'F' || additionalTV == 'f')
- additionalPrice = 25.00;
- else if(additionalTV == 'L' || additionalTV == 'l')
- additionalPrice = 20.00;
- else
- additionalPrice = 0;
- } else {
- packagePrice = 125.00;
- if(additionalTV == 'S' || additionalTV == 's')
- additionalPrice = 35.00;
- else
- additionalPrice = 0;
- }
- totalBeforeTax = packagePrice + additionalPrice;
- totalWithTax = totalBeforeTax + (totalBeforeTax * 0.06);
- }
- void receipt(string smartCard, char packageCode, char additionalTV, double totalBeforeTax, double totalWithTax){
- string packageName;
- if(packageCode == 'A' || packageCode == 'a')
- packageName = "Astro Family Pack";
- else if(packageCode == 'B' || packageCode == 'b')
- packageName = "Astro Family HD Pack";
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << "----------------------------------------------------------------\n";
- cout << "ASTRO BILLING SERVICE\n";
- cout << "Smart Card No. : " << smartCard << endl;
- cout << "Package Name : " << packageName << endl;
- cout << "Additional TV Series : " << additionalTV << endl;
- cout << "Total Charge (RM) : " << totalBeforeTax << endl;
- cout << "New charge after 6% govt. tax (RM) : " << totalWithTax << endl;
- }
Add Comment
Please, Sign In to add comment