the variables are extracted from a file.
Expand|Select|Wrap|Line Numbers
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- void thankYou();
- void showMenu();
- int main(int argc, char *argv[])
- {
- const int SIZE = 60;
- const int ADDRESS_SIZE =128;
- char status[SIZE];
- char fname[SIZE];
- char lname[SIZE];
- char phoneNum[SIZE];
- char streetAdd[ADDRESS_SIZE];
- double transAmount;
- char choice;
- char again;
- fstream people;
- ofstream outFile;
- people.open ("C:\\potentials.txt");
- if(!people)
- {
- cout <<" Error opening file.\n";
- system("PAUSE");
- return EXIT_FAILURE;
- }
- outFile.open("C:\\confirmed.txt");
- if(!outFile)
- {
- cout <<" Error opening file confirmed.\n";
- system("PAUSE");
- return EXIT_FAILURE;
- }
- cout <<" Here are the Potential Customers:\n\n";
- people >> status;
- people >> fname;
- people >> lname;
- people >> phoneNum;
- do
- {
- if(!strcmp(status, "X"))
- {
- cout <<" "<< fname <<" "<< lname <<" "<< phoneNum
- << " Gets a 6.9% interest rate.\n";
- }
- else
- {
- cout <<" "<< fname <<" "<< lname <<" "<< phoneNum
- << " Gets a 12.9% interest rate.\n";
- }
- showMenu();
- cin >> choice;
- cin.ignore();
- switch(choice)
- {
- case 'a':
- case 'A':
- {
- cout <<" Ask for their Address and enter it here:\n";
- cin.getline(streetAdd, ADDRESS_SIZE);
- outFile << fname <<" "<< lname <<" "<< status <<" "
- << streetAdd <<" New customer" << endl;
- system("cls");
- thankYou();
- break;
- }
- case 't':
- case 'T':
- {
- if(!strcmp(status, "X"))
- {
- cout <<" Enter transfer amount.\n";
- cin >> transAmount;
- cin.ignore();
- cout <<" Ask for their Address and enter it here:\n";
- cin.getline(streetAdd, ADDRESS_SIZE);
- outFile << setprecision(2) << fixed;
- outFile << fname <<" "<< lname <<" "<< status
- <<" "<< streetAdd <<" Transfer: $"<< transAmount << endl;
- system("cls");
- thankYou();
- break;
- }
- else
- {
- cout <<" You can transfer up to $1000.00.\n";
- cout <<" Enter transfer amount: ";
- cin >> transAmount;
- cin.ignore();
- cout <<" Ask for their Address and enter it here:\n";
- cin.getline(streetAdd, ADDRESS_SIZE);
- outFile << fname <<" "<< lname <<" "<< status
- <<" "<< streetAdd <<" Transfer: $"<< transAmount << endl;
- system("cls");
- thankYou();
- break;
- while(transAmount <= 0 || transAmount > 1000.00)
- {
- cout <<" Please enter an amount of $1000.00 "
- <<" or less.\n";
- cin >> transAmount;
- cout <<" Ask for their Address and enter it here:\n";
- cin.getline(streetAdd, ADDRESS_SIZE);
- outFile << fname <<" "<< lname <<" "<< status
- <<" "<< streetAdd <<" Transfer: $"<< transAmount << endl;
- thankYou();
- cin.ignore();
- break;
- }
- }
- }
- case 'd':
- case 'D':
- {
- if(!strcmp(status, "X") == 1)
- {
- system("cls");
- cout <<" Call 1-800-ROBmeTO for special CASH back rewards.\n"
- <<" Don't miss out!\n";
- break;
- }
- else
- {
- system("cls");
- cout <<" Thank you for your time and have a nice day.\n";
- break;
- }
- }
- }
- people >> status;
- people >> fname;
- people >> lname;
- people >> phoneNum;
- cout <<"\n Press the enter key to get the next record.\n";
- cin.get(again);
- }while(!people.eof());
- cout <<" That is all the data in the file!\n";
- people.close();
- outFile.close();
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- void showMenu()
- {
- cout <<" \n\t\tCredit Card Menu\n\n"
- <<" Choose from the following menu.\n\n"
- <<" A --> If they (A)ccept the card\n"
- <<" T --> If they want to (T)ransfer a balance\n"
- <<" D --> If they (D)ecline the card\n"
- <<"\n Enter their choice\n";
- }
- void thankYou()
- {
- const int SIZE = 60;
- char fname[SIZE];
- char lname[SIZE];
- cout <<"\n\tCongradulations\n" << fname <<" "<< lname << endl;
- cout <<" Your card will arrive by mail soon.\n";
- cout <<" On behalf of RobMeBlind Credit Card Company\n";
- cout <<" I would like to thank you for your order and\n";
- cout <<" wish you happy shopping.\n";
- }