Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- //Creating Global Variable
- float iniLoad = 500.00;
- float loaded = 0.0;
- char resp = '0';
- int arrayCtr = 2;
- int tranNo[10] = {1,2,3};
- string mobNo[10] = {"0918-000-1234", "0918-000-1235", "0918-000-1236"};
- string tranDate[10] = {"09-21-2019", "09-20-2019", "09-19-2019"} ;
- float tranAmt[10] = {100.00, 200.00, 300.00};
- string mes = "3 transaction(s) recorded ...";
- void Line(char h, int reps){
- for (int i=1; i <= reps; i++){
- cout << h;
- }
- cout << endl;
- }
- void Load1() {
- int xTran = 0;
- string xMob = "";
- string xDat = "";
- float xAmt = 0.0;
- Line('-',75);
- cout << " Loading Transaction >>> " << endl;
- arrayCtr = arrayCtr + 1;
- xTran = arrayCtr + 1;
- cout << " Transaction ID: " << xTran << endl;
- cout << " Mobile Number : ";
- cin >> xMob;
- cout << " Date : ";
- cin >> xDat;
- cout << " Load Amount : ";
- cin >> xAmt;
- if (xAmt > iniLoad) {
- mes = " Balance Load not sufficient to complete the transaction!\n Loading cancelled... ";
- arrayCtr = arrayCtr - 1;
- } else {
- iniLoad = iniLoad - xAmt;
- mes = " Loading completed... Transaction recorded!";
- tranNo[arrayCtr] = xTran;
- mobNo[arrayCtr] = xMob;
- tranDate[arrayCtr] = xDat;
- tranAmt[arrayCtr] = xAmt;
- }
- }
- void Modify1(int recID) {
- int xTran = 0;
- float yAmt = 0.0;
- float tAmt = 0.0;
- int aCtr = 0;
- Line('-',75);
- cout << " Edit Amount >>> " << endl;
- cout << " Transaction ID: ";
- cin >> xTran;
- aCtr = recID + 1;
- if (xTran <= aCtr ) {
- string xMob = mobNo[recID];
- string xDat = tranDate[recID];
- float xAmt = tranAmt[recID];
- cout << " Mobile Number : " << xMob << endl;
- cout << " Date : " << xDat << endl;
- cout << " Load Amount : ";
- cin >> yAmt;
- if (yAmt >= xAmt) {
- tAmt = yAmt - xAmt;
- if (tAmt > iniLoad) {
- mes = "Balance Load insufficient to complete the transaction! Editing cancelled...";
- } else {
- iniLoad = iniLoad - tAmt;
- mes = "Transaction Modified!";
- tranAmt[recID] = yAmt;
- }
- } else {
- tAmt = xAmt - yAmt;
- iniLoad = iniLoad + tAmt;
- mes = "Transaction Modified!";
- tranAmt[recID] = yAmt;
- }
- } else {
- mes = "No Record Found!";
- }
- }
- void Reload1(){
- Line('-',75);
- string cn;
- char la;
- cout << " Reloading >>> " << endl;
- cout << " Credit Card Number: ";
- cin >> cn;
- cout << " Select Load Amount [1] 500.00 [2] 1000.00 [3] 5000.00 : ";
- cin >> la;
- if (la == '1') {
- mes = "450.00 Pesos deducted to your Credit Card";
- iniLoad = iniLoad + 500;
- } else if (la == '2') {
- mes = "900.00 Pesos deducted to your Credit Card";
- iniLoad = iniLoad + 1000;
- } else if (la == '3') {
- mes = "4,000.00 Pesos deducted to your Credit Card";
- iniLoad = iniLoad + 5000;
- } else {
- mes = "Reloading Failed!";
- }
- }
- int main() {
- cout << fixed << setprecision(2);
- while (resp != '4') {
- system("cls");
- Line('-', 75);
- cout << " Loading Station" << endl;
- Line('-', 75);
- cout << " Recent Transaction(s) >>> \n" << endl;
- cout << " ID ";
- cout << "Mobile Number ";
- cout << "Date ";
- cout << " Amount Loaded" << endl;
- loaded = 0;
- for (int i=0; i <= arrayCtr; i++) {
- cout << " ";
- cout << tranNo[i] << " ";
- cout << mobNo[i] << " ";
- cout << tranDate[i] << " ";
- cout << tranAmt[i] << endl;
- loaded = loaded + tranAmt[i];
- }
- Line('-', 75);
- cout << " Account Status >>> ";
- cout << " Amount Loaded : " << loaded;
- cout << " Balance Load : " << iniLoad << endl;
- if (iniLoad < 100.00) {
- mes = "Reload immediately... Load Balance is in critical level! ";
- }
- cout << " Status: " << mes << endl;
- Line('-', 75);
- cout << " Transaction >>> \n\n" << " ";
- cout << "[1]Load ";
- cout << "[2]Modify ";
- cout << "[3]Reload Account ";
- cout << "[4] Exit\n" << endl;
- Line('-', 75);
- cout << " Select: ";
- cin >> resp;
- if (resp == '1') {
- Load1();
- } else if (resp == '2') {
- Modify1(arrayCtr);
- } else if (resp == '3') {
- Reload1();
- } else if (resp == '4') {
- system("cls");
- cout << endl;
- Line('-', 75);
- cout << "-- Thank you for using Loading Station App --" << endl;
- Line('-', 75);
- cout << "\n \n \n" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment