This program compiles and lets me select a letter from the menu, but then it just repeats the menu, it never outputs the statements that correspond with the letter chosen. Any ideas why?
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
using namespace std;
//Function Prototypes
void accept ();
void transfer ();
void decline ();
int menu ();
int main()
{
const int SIZE = 100; //Length of line
char first[SIZE], last[SIZE], phone[SIZE], status;
int X;
ifstream inputFile;
inputFile.open ("c:\\potentials.txt", ios::in);
if (inputFile.fail())
{
cout << "Error opening file. The file could not be found.\n";
cout <<""<<endl;
system ("PAUSE");
return EXIT_FAILURE;
}
// Determine status
inputFile >> status;
if (status == 'X' || status == 'x')
{
cout << "Preferred -- 7.9%" << endl;
}
else if (!(status == 'X' || status == 'x'))
{
cout << "12.9%" << endl;
}
// Get name
inputFile >> first >> last;
cout << first << " " << last << endl;
// Get phone number
inputFile >> phone;
cout << phone << endl;
cout << "" << endl;
char selection;
do
{
selection = menu ();
switch (selection)
{
case 1: accept ();
break;
case 2: transfer ();
break;
case 3: decline ();
break;
}
} while (1);
return 0;
}
//******************************************************************************
// Definition of function menu. *
// Displays the menu and asks user to select an option. *
//******************************************************************************
int menu ()
{
char letter;
cout << "Please press the corresponding letter for the option you would like:" << endl;
cout << "" << endl;
cout << "A -- Accept the credit card" << endl;
cout << "T -- Transfer a balance" << endl;
cout << "D -- Decline the card" << endl;
cout << "" << endl;
cout << "Please enter your choice:" << endl;
cin >> letter;
cout << "" << endl;
while ((letter == 'T' || letter == 't') && (letter =='A' || letter =='a') && (letter == 'D' || letter == 'd'))
{
cout << "Invalid Selection. Enter A, T or D:" << endl;
cin >> letter;
}
return letter;
}
//******************************************************************************
// Definition for letter choice A. *
// This function is for customers who choose to accept the card offer. *
//******************************************************************************
void accept ()
{
char letter, address;
if (letter == 'A' || letter == 'a')
{
cout << "Ask the customer for their address and enter it here: " << endl;
cin >> address;
cout << "" << endl;
cout << "Tell The customer, ' Thank you for your order today, expect" <<
cout << " your card to arrive in the mail soon, happy charging.'" << endl;
cout << endl;
}
}
//******************************************************************************
// Definition for letter choice T. *
// This function is for customers who choose to accept the card offer. *
//******************************************************************************
void transfer ()
{
char address, letter, status;
int tamount;
if (letter == 'T' || letter == 't' && status == 'X' || status == 'x')
{
cout << "There is no transfer limit. How much would you like to transfer?" << endl;
cin >> tamount;
cout << "" << endl;
cout << "Ask the customer for their address and enter it here: " << endl;
cin >> address;
cout << "" << endl;
cout << "Tell The customer, ' Thank you for your order today, expect" <<
cout << " your card to arrive in the mail soon, happy charging.'" << endl;
cout << endl;
}
else if (letter == 'T' || letter == 't' && !(status == 'X' || status == 'x')&& tamount <=1000)
{
cout << "There is a transfer limit of $1000.00. How much would you like to transfer?" << endl;
cin >> tamount;
cout << "" << endl;
cout << "Ask the customer for their address and enter it here: " << endl;
cin >> address;
cout << "" << endl;
cout << "Tell The customer, ' Thank you for your order today, expect" <<
cout << " your card to arrive in the mail soon, happy charging.'" << endl;
cout << endl;
}
else if (letter == 'T' || letter == 't' && !(status == 'X' || status == 'x') && tamount <=1000)
{
cout << "There is a transfer limit of $1000.00. How much would you like to transfer?" << endl;
cin >> tamount;
cout << "You have entered an amount over the transfer limit, please try again." << endl;
cout <<""<<endl;
}
}
//******************************************************************************
// Definition for letter choice D. *
// This function is for customers who choose to accept the card offer. *
//******************************************************************************
void decline ()
{
char letter, status;
if (letter == 'D' || letter == 'd' && status == 'X' || status == 'x')
{
cout << "Tell then customer, 'There are amazing cash back rewards available to you!" <<
cout << " Please call 888-555-1234 for a deal you won't be able to pass on!" << endl;
cout << "" << endl;
}
else if (letter == 'D' || letter == 'd' && !(status == 'X' || status == 'x'))
{
cout << "Thank you for your time and consideration. Goodbye." << endl;
cout << "" << endl;
}
}