1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
//------------------------------------------------------------------------------
//Program Description
//Create an application for a credit card company that allows
//the user to make a purchase using the credit card, transfer a balance from
//another credit card, calculate the minimum credit card payment
//due and view their available credit line.
//------------------------------------------------------------------------------
#include <iostream>
void getPin(int& pin);
bool isValidPin(int pin);
void getAmount(double& amount);
void makePurchase(double amount, double& currentLimit);
void creditTransfer(double amount, double& creditLimit);
void minPayment(double creditLimit);
int main()
{
using namespace std;
int input;
getPin(input);
isValidPin(input);
return 0;
}
void getPin(int& pin)
{
using namespace std;
cout << "Please enter the pin" << endl;
cin >> pin;
}
bool isValidPin (int pin)
{
using namespace std;
int input_category;
double cost, creditMax = 1000;
if (pin == 1234)
{
do
{
cout << "1. Pay for purchase" << endl;
cout << "2. Balance transfer from another credit card" << endl;
cout << "3. Calculate minimum payment" << endl;
cout << "4. View available credit limit" << endl;
cout << "5. Exit" << endl;
cin >> input_category;
switch (input_category)
{
case 1:
getAmount(cost);
makePurchase(cost, creditMax);
break;
case 2:
getAmount(cost);
creditTransfer(cost, creditMax);
break;
case 3:
minPayment(creditMax);
break;
case 4:
cout << "Your credit limit is $";
cout << creditMax << endl;
break;
case 5:
cout << "Thank You." << endl;
return 0;
break;
}
}while((input_category > 0) && (input_category <= 5));
cout << "Incorrect Entry." << endl;
}
else
{
cout << "Incorrect Pin Entry" << endl;
}
return false;
}
void getAmount(double& amount)
{
using namespace std;
double currentLimit;
cout << "Please enter the amount " << endl;
cin >> amount;
if (amount <= currentLimit)
{
cout << "Transaction is successful.";
}
else
{
cout << "Insufficient Funds." << endl;
}
}
void makePurchase(double amout, double& currentLimit)
{
using namespace std;
double creditLimit = 1000.00, amount;
currentLimit = creditLimit - amount;
cout << " Your credit limit after transaction is $";
cout << currentLimit << endl;
}
void creditTransfer(double amount, double& creditLimit)
{
using namespace std;
double total_charge, currentLimit;
total_charge = amount + 10.00;
currentLimit -= total_charge;
if (total_charge <= currentLimit)
{
cout << "Your credit limit after transaction is $";
cout << currentLimit << endl;
}
else
{
cout << "Insufficient Funds." << endl;
}
}
void minPayment(double creditLimit)
{
using namespace std;
double payMin, currentLimit;
payMin = (creditLimit - currentLimit) * 0.05;
cout << "Your minimum payment is $";
cout << payMin << endl;
return;
}
|