Rainrix2001

Array

Sep 25th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. //Creating Global Variable
  5. float iniLoad = 500.00;
  6. float loaded = 0.0;
  7. char resp = '0';
  8. int arrayCtr = 2;
  9. int tranNo[10] = {1,2,3};
  10. string mobNo[10] = {"0918-000-1234", "0918-000-1235", "0918-000-1236"};
  11. string tranDate[10] = {"09-21-2019", "09-20-2019", "09-19-2019"} ;
  12. float tranAmt[10] = {100.00, 200.00, 300.00};
  13. string mes = "3 transaction(s) recorded ...";
  14. void Line(char h, int reps){
  15.  for (int i=1; i <= reps; i++){
  16.  cout << h;
  17.  }
  18.  cout << endl;
  19. }
  20. void Load1() {
  21.  int xTran = 0;
  22.  string xMob = "";
  23.  string xDat = "";
  24.  float xAmt = 0.0;
  25.  Line('-',75);
  26.  cout << " Loading Transaction >>> " << endl;
  27.  arrayCtr = arrayCtr + 1;
  28.  xTran = arrayCtr + 1;
  29.  cout << " Transaction ID: " << xTran << endl;
  30.  cout << " Mobile Number : ";
  31.  cin >> xMob;
  32.  cout << " Date : ";
  33.  cin >> xDat;
  34.  cout << " Load Amount : ";
  35.  cin >> xAmt;
  36.  if (xAmt > iniLoad) {
  37.  mes = " Balance Load not sufficient to complete the transaction!\n Loading cancelled... ";
  38.  arrayCtr = arrayCtr - 1;
  39.  } else {
  40.  iniLoad = iniLoad - xAmt;
  41.  mes = " Loading completed... Transaction recorded!";
  42.  tranNo[arrayCtr] = xTran;
  43.  mobNo[arrayCtr] = xMob;
  44.  tranDate[arrayCtr] = xDat;
  45.  tranAmt[arrayCtr] = xAmt;
  46.  }
  47. }
  48. void Modify1(int recID) {
  49.  int xTran = 0;
  50.  float yAmt = 0.0;
  51.  float tAmt = 0.0;
  52.  int aCtr = 0;
  53.  Line('-',75);
  54.  cout << " Edit Amount >>> " << endl;
  55.  cout << " Transaction ID: ";
  56.  cin >> xTran;
  57.  aCtr = recID + 1;
  58.  if (xTran <= aCtr ) {
  59.  string xMob = mobNo[recID];
  60.  string xDat = tranDate[recID];
  61.  float xAmt = tranAmt[recID];
  62.  cout << " Mobile Number : " << xMob << endl;
  63.  cout << " Date : " << xDat << endl;
  64.  cout << " Load Amount : ";
  65.  
  66.  cin >> yAmt;
  67.  if (yAmt >= xAmt) {
  68.  tAmt = yAmt - xAmt;
  69.  if (tAmt > iniLoad) {
  70.  mes = "Balance Load insufficient to complete the transaction! Editing cancelled...";
  71.  } else {
  72.  iniLoad = iniLoad - tAmt;
  73.  mes = "Transaction Modified!";
  74.  tranAmt[recID] = yAmt;
  75.  }
  76.  } else {
  77.  tAmt = xAmt - yAmt;
  78.  iniLoad = iniLoad + tAmt;
  79.  mes = "Transaction Modified!";
  80.  tranAmt[recID] = yAmt;
  81.  }
  82.  } else {
  83.  mes = "No Record Found!";
  84.  }
  85.  
  86. }
  87. void Reload1(){
  88.  Line('-',75);
  89.  string cn;
  90.  char la;
  91.  cout << " Reloading >>> " << endl;
  92.  cout << " Credit Card Number: ";
  93.  cin >> cn;
  94.  cout << " Select Load Amount [1] 500.00 [2] 1000.00 [3] 5000.00 : ";
  95.  cin >> la;
  96.  if (la == '1') {
  97.  mes = "450.00 Pesos deducted to your Credit Card";
  98.  iniLoad = iniLoad + 500;
  99.  } else if (la == '2') {
  100.  mes = "900.00 Pesos deducted to your Credit Card";
  101.  iniLoad = iniLoad + 1000;
  102.  } else if (la == '3') {
  103.  mes = "4,000.00 Pesos deducted to your Credit Card";
  104.  iniLoad = iniLoad + 5000;
  105.  } else {
  106.  mes = "Reloading Failed!";
  107.  }
  108. }
  109. int main() {
  110.  cout << fixed << setprecision(2);
  111.  while (resp != '4') {
  112.  system("cls");
  113.  Line('-', 75);
  114.  cout << " Loading Station" << endl;
  115.  Line('-', 75);
  116.  cout << " Recent Transaction(s) >>> \n" << endl;
  117.  cout << " ID ";
  118.  cout << "Mobile Number ";
  119.  cout << "Date ";
  120.  cout << " Amount Loaded" << endl;
  121.  loaded = 0;
  122.  for (int i=0; i <= arrayCtr; i++) {
  123.  cout << " ";
  124.  cout << tranNo[i] << " ";
  125.  cout << mobNo[i] << " ";
  126.  cout << tranDate[i] << " ";
  127.  cout << tranAmt[i] << endl;
  128.  loaded = loaded + tranAmt[i];
  129.  }
  130.  Line('-', 75);
  131.  cout << " Account Status >>> ";
  132.  cout << " Amount Loaded : " << loaded;
  133.  cout << " Balance Load : " << iniLoad << endl;
  134.  if (iniLoad < 100.00) {
  135.  
  136.  mes = "Reload immediately... Load Balance is in critical level! ";
  137.  }
  138.  cout << " Status: " << mes << endl;
  139.  Line('-', 75);
  140.  cout << " Transaction >>> \n\n" << " ";
  141.  cout << "[1]Load ";
  142.  cout << "[2]Modify ";
  143.  cout << "[3]Reload Account ";
  144.  cout << "[4] Exit\n" << endl;
  145.  Line('-', 75);
  146.  cout << " Select: ";
  147.  cin >> resp;
  148.  if (resp == '1') {
  149.  Load1();
  150.  } else if (resp == '2') {
  151.  Modify1(arrayCtr);
  152.  } else if (resp == '3') {
  153.  Reload1();
  154.  } else if (resp == '4') {
  155.  system("cls");
  156.  cout << endl;
  157.  Line('-', 75);
  158.  cout << "-- Thank you for using Loading Station App --" << endl;
  159.  Line('-', 75);
  160.  cout << "\n \n \n" << endl;
  161.  }
  162.  }
  163.  return 0;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment