Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //These are called libraries that define a certain thing within the program that each do different things.
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- #include <iomanip>
- //This removes the STD:: in c++ so it is easier to code.
- using namespace std;
- //Base account class that I made called BaseAccount
- class BaseAccount {
- //Protected makes them not be able to identify outside the class
- protected:
- //Int stores integers,such as whole numbers
- int freeData;
- int freeCalls;
- int freeTexts;
- int freeMins;
- //Bool is short for boolean which can store values with either true or false
- bool freeNum;
- bool pinkTether;
- int userData;
- int userCalls;
- int userTexts;
- int userMins;
- const float dataCost = 3.19;
- const float callCost = 1.99;
- const float textCost = 0.99;
- const float minsCost = 0.20;
- //Stores whole numbers with decimals
- double monthlyCostVAT;
- double monthlyCost;
- double dataTotal;
- double callTotal;
- double textTotal;
- double minsTotal;
- //Anything under public can be accessed by anybody
- public:
- //Void lets me set any piece of work into the application at any time that I can later use
- void setFreeData(int fData) {
- freeData = fData;
- }
- void setFreeCalls(int fCalls) {
- freeCalls = fCalls;
- }
- void setFreeTexts(int fTexts) {
- freeTexts = fTexts;
- }
- void setFreeMins(int fMins) {
- freeMins = fMins;
- }
- void setFreeNum(bool fNum) {
- freeNum = fNum;
- }
- void setPinkTether(bool pTether) {
- pinkTether = pTether;
- }
- void setMonthlyCost(double mCost) {
- monthlyCost = mCost;
- }
- void setUserCalls(double uCalls) {
- userCalls = uCalls;
- }
- void setUserData(double uData) {
- userData = uData;
- }
- void setUserTexts(double uTexts) {
- userTexts = uTexts;
- }
- //These are all my calculations for all the data, calls, texts and minutes they are using
- double calcDataCost() {
- if (userData > freeData) {
- dataTotal = (userData - freeData) * dataCost;
- }
- else {
- dataTotal = 0;
- }
- return dataTotal;
- }
- double calcCallCost() {
- if (userCalls > freeCalls) {
- callTotal = (userCalls - freeCalls) * callCost;
- }
- else {
- callTotal = 0;
- }
- return callTotal;
- }
- double calcTextCost() {
- if (userTexts > freeTexts) {
- textTotal = (userTexts - freeTexts) * textCost;
- }
- else {
- textTotal = 0;
- }
- return textTotal;
- }
- double calcMinCost() {
- if (userMins > freeMins) {
- minsTotal = (userMins - freeMins) * minsCost;
- }
- else {
- minsTotal = 0;
- }
- return minsTotal;
- }
- //These are the true or false booleans that are getting so I can declare it later on when calling the booleans
- bool getFreeNum() {
- return freeNum;
- }
- bool getPinkTether() {
- return pinkTether;
- }
- double getMonthlyCost() {
- return monthlyCost;
- }
- //This is the basic input of the MonthlyCostVAT that I need for the VAT to work and calculate correcly
- double getMonthlyCostVAT() {
- calcDataCost();
- calcCallCost();
- calcTextCost();
- calcMinCost();
- return (dataCost + minsCost + callCost + textCost + monthlyCost) * 20;
- }
- };
- //This is my pinkLight class that I made with the BaseAccount implementation at the top
- class Light : public BaseAccount {
- public:
- Light() {
- setFreeData(500);
- setFreeCalls(1000);
- setFreeTexts(300);
- setMonthlyCost(14.99);
- setPinkTether(false);
- setFreeNum(false);
- }
- };
- //This is my pinkData class that I made with the BaseAccount implementation at the top
- class Data : public BaseAccount {
- public:
- Data() {
- setFreeData(5000);
- setFreeCalls(10000);
- setFreeTexts(500);
- setMonthlyCost(24.99);
- setPinkTether(true);
- setFreeNum(false);
- }
- };
- //This is my pinkFreedom class that I made with the BaseAccount implementation at the top
- class Freedom : public BaseAccount {
- public:
- Freedom() {
- setFreeData(20000);
- setFreeTexts(1000);
- setMonthlyCost(34.99);
- setPinkTether(true);
- setFreeNum(true);
- }
- };
- bool exitProg = false;
- int menu1Option;
- char userName[20];
- int packageType;
- int dataAmount;
- int callAmount;
- int textAmount;
- int minsAmount;
- string menu2[5] = {
- "Please Enter Your Name.",
- "Please Choose Your Package Type.",
- "1 - Light",
- "2 - Data",
- "3 - Freedom" };
- Light lAccount;
- Data dAccount;
- Freedom fAccount;
- //Main is the basic function that will get caught inside the exitProg boolean that creates the GUI for people to use
- int main() {
- while (!exitProg) {
- //This is the menu and options so that someone can input a number and it will navigate them through the application.
- cout << "Please Choose An Option:" << endl;
- cout << "0 - Exit" << endl;
- cout << "1 - Enter User Details And Choose Account Type" << endl;
- cout << "2 - Enter Usage Details" << endl;
- cout << "3 - Display Bill" << endl;
- cout << "4 - Display Package Information" << endl;
- cin >> menu1Option;
- //system,cls will clear the input when the program runs through it
- system("CLS");
- //Basic if statement that prompts the user to exit the program with "Y" or "N"
- if (menu1Option == 0) {
- char choice;
- cout << "Are you sure you want to exit the program? Type 'Y' or 'N'" << endl;
- cin >> choice;
- //If they have chosen Y then the program will exit but if they chose N it will then exit
- if (choice == 'Y' || choice == 'y') {
- exitProg = true;
- }
- else {
- exitProg = false;
- system("CLS");
- }
- }
- if (menu1Option == 1) {
- cout << menu2[0] << endl;
- cin.ignore();
- cin.getline(userName, 20);
- system("CLS");
- cout << menu2[1] << endl;
- cout << menu2[2] << endl;
- cout << menu2[3] << endl;
- cout << menu2[4] << endl;
- cin >> packageType;
- system("CLS");
- if (packageType == 1) {
- cout << "You've Chosen Light As An Account Type." << endl;
- //system,pause will pause the program and display a msg saying press any button to continue which continues them onto the next page
- system("PAUSE");
- system("CLS");
- }
- if (packageType == 2) {
- cout << "You've Chosen Data As An Account Type." << endl;
- system("PAUSE");
- system("CLS");
- }
- if (packageType == 3) {
- cout << "You've Chosen Freedom As An Account Type." << endl;
- system("PAUSE");
- system("CLS");
- }
- }
- //Error checking that will display if they haven't chosen a package type and will return them to the main menu
- if (menu1Option == 2) {
- if (packageType == NULL) {
- cout << "Make Sure You Have Chosen An Account Type." << endl;
- system("PAUSE");
- system("CLS");
- }
- else {
- cout << "Enter Amount Of Data: ";
- cin >> dataAmount;
- cout << "Enter Amount Of Calls: ";
- cin >> callAmount;
- cout << "Enter Amount Of Texts: ";
- cin >> textAmount;
- cout << "Enter Amount Of Minutes: ";
- cin >> minsAmount;
- if (packageType == 1) {
- lAccount.setUserData(dataAmount);
- lAccount.setUserCalls(callAmount);
- lAccount.setUserData(textAmount);
- lAccount.setUserCalls(minsAmount);
- }
- if (packageType == 2) {
- dAccount.setUserData(dataAmount);
- dAccount.setUserCalls(callAmount);
- dAccount.setUserData(textAmount);
- dAccount.setUserCalls(minsAmount);
- }
- if (packageType == 3) {
- fAccount.setUserData(dataAmount);
- fAccount.setUserCalls(callAmount);
- fAccount.setUserData(textAmount);
- fAccount.setUserCalls(minsAmount);
- }
- cout << "Your Info Has Been Stored" << endl;
- system("PAUSE");
- system("CLS");
- }
- }
- //Error checking that will display if they haven't chosen a package type and will return them to the main menu
- if (menu1Option == 3) {
- if (packageType == NULL) {
- cout << "Make Sure You Have Chosen An Account Type." << endl;
- system("PAUSE");
- system("CLS");
- }
- else {
- //Displays their billing total with and without vat
- cout << "Your Billing Total is: " << endl;
- if (packageType == 1) {
- cout << "Without VAT it comes up to: " << "\x9c" << lAccount.getMonthlyCost() << endl;
- cout << "With VAT it comes up to: " << "\x9c" << fixed << setprecision(2) << lAccount.getMonthlyCostVAT() << endl;
- }
- if (packageType == 2) {
- cout << "Without VAT it comes up to: " << "\x9c" << dAccount.getMonthlyCost() << endl;
- cout << "With VAT it comes up to: " << "\x9c" << fixed << setprecision(2) << dAccount.getMonthlyCostVAT() << endl;
- }
- if (packageType == 3) {
- cout << "Without VAT it comes up to: " << "\x9c" << fAccount.getMonthlyCost() << endl;
- cout << "With VAT it comes up to: " << "\x9c" << fixed << setprecision(2) << fAccount.getMonthlyCostVAT() << endl;
- }
- system("PAUSE");
- system("CLS");
- }
- }
- //Error checking that will display if they haven't chosen a package type and will return them to the main menu
- if (menu1Option == 4) {
- if (packageType == NULL) {
- cout << "Make Sure You Have Chosen An Account Type." << endl;
- system("PAUSE");
- system("CLS");
- }
- else {
- //This shall display the basic information about the package type they chose and the boolean
- if (packageType == 1) {
- cout << "PINK LIGHT PACKAGE INFORMATION" << endl;
- cout << "With Pink Light, you are allowed to have 500MB of data free, 300 texts and 1000 minutes of free calls." << endl;
- //These are the booleans that I displayed to say if they are allowed to have pink tether or call 080 numbers for free
- //Boolalpha is making the boolean display true or false instead of 1 or 0
- cout << "This is the output whether you are allowed pink tether" << " >> " << boolalpha << false << " << " << endl;
- cout << "This is the output whether you are allowed free 080 numbers" << " >> " << boolalpha << false << " << " << endl;
- }
- if (packageType == 2) {
- cout << "PINK DATA PACKAGE INFORMATION" << endl;
- cout << "With Pink Data, you are allowed to have 5GB of data free, 500 texts and unlimited calls." << endl;
- cout << "This is the output whether you are allowed pink tether" << " >> " << boolalpha << true << " << " << endl;
- cout << "This is the output whether you are allowed free 080 numbers" << " >> " << boolalpha << false << " << " << endl;
- }
- if (packageType == 3) {
- cout << "PINK FREEDOM PACKAGE INFORMATION" << endl;
- cout << "With Pink Freedom, you are allowed to have 20GB of data free, 1000 texts and unlimited calls." << endl;
- cout << "This is the output whether you are allowed pink tether" << " >> " << boolalpha << true << " << " << endl;
- cout << "This is the output whether you are allowed free 080 numbers" << " >> " << boolalpha << true << " << " << endl;
- }
- system("PAUSE");
- system("CLS");
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement