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
|
#include <iostream>
#include <fstream>
using namespace std;
int itemSelect();
int paymentsel();
int paymentfunc(int x, double y);
int receipt(int x, double y);
int cash(double y);
int endprogram();
int receipt2(int x, double y, double z, double a);
int main()
{
paymentsel();
return 0;
}
int paymentsel()
{
double total=0;
ifstream input("rtotal.txt");
input >> total;
cout << total << endl << endl;
cout << "Please enter payment type:" << endl;
cout << "1 - CASH" << endl;
cout << "2 - DEBIT" << endl;
cout << "3 - CREDIT" << endl << endl;
cout << "PAYMENT TYPE: ";
int paymenttype;
cin >> paymenttype;
paymentfunc(paymenttype, total);
}
int paymentfunc(int x, double y)
{
switch (x)
{
case 1 :
cash(y);
break;
case 2 :
receipt(x, y);
break;
case 3 :
receipt(x, y);
break;
default :
cout << "ERROR" << endl;
paymentsel();
}
}
int cash(double y)
{
double tax;
double change;
tax = y * 0.065;
double check = tax + y;
cout << "\nFINAL TOTAL - $" << check << endl;
cout << "Enter in amount given: ";
double amount;
cin >> amount;
if (amount < check )
{
cout << "Error. Insufficient Funds." << endl << endl;
cash(y);
}
receipt2(amount, y, tax, check);
change = amount - y;
}
int receipt(int x, double y)
{
ofstream receipt;
receipt.open ("receipt.txt");
receipt << "THANK YOU FOR SHOPPING AT" << endl << endl;
receipt << "================================" << endl << endl;
receipt << "Your total is - $" << y << endl;
double tax;
tax = 0.065 * y;
receipt << "Tax - $" << tax << endl << endl;
receipt << "FINAL TOTAL - $" << y + tax << endl << endl;
receipt << "Total has been charged to card." << endl << endl;
receipt.close();
endprogram();
}
int receipt2(int x, double y, double z, double a)
{
ofstream receipt;
receipt.open ("receipt.txt");
receipt << "THANK YOU FOR SHOPPING AT " << endl << endl;
receipt << "================================" << endl << endl;
receipt << "Your total is - $" << y << endl;
receipt << "Tax - $" << z << endl << endl;
receipt << "FINAL TOTAL - $" << y + z << endl << endl;
receipt << "Amount Cash Given - $" << x << endl;
double change = x - a;
receipt << "Change - $" << change << endl << endl;
receipt.close();
cout << "Change due is: " << change<< endl;
endprogram();
}
int endprogram()
{
cout << "Transaction finished." << endl;
system("pause");
return 0;
}
|