Hey all,
I have a couple of compiler errors that I'm running into that I can't figure out how to correct them. The assignment calls for a program that simulates an ATM menu, using classes and objects. I keep getting the following compiler errors:
1>------ Build started: Project: Lab06, Configuration: Debug Win32 ------
1> MenuBuilderClass.cpp
1>c:\users\user\documents\visual studio 2012\projects\lab06\lab06\menubuilderclass.cpp(97) : warning C4715: 'processAnswer' : not all control paths return a value
1>TestMenu.obj : error LNK2019: unresolved external symbol "public: int __thiscall MenuBuilder::buildMenu(void)" (?buildMenu@MenuBuilder@@QAEHXZ) referenced in function _main
1>TestMenu.obj : error LNK2019: unresolved external symbol "public: int __thiscall MenuBuilder:rocessAnswer(int)" (?processAnswer@MenuBuilder@@QAEHH@Z) referenced in function _main
1>C:\Users\User\Documents\Visual Studio 2012\Projects\Lab06\Debug\Lab06.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The code I have is below:
Menubuilder.h
Code:
#ifndef MENU_BUILDER_H
#define MENU_BUILDER_H
using namespace std;
class MenuBuilder
{
public:
MenuBuilder();
int buildMenu();
int processAnswer(int);
private:
double CurrBal;
};
#endif
MenuBuilderClass.cpp
Code:
#include <iostream>
#include "MenuBuilder.h"
using namespace std;
MenuBuilder::MenuBuilder()
{
double CurrBal = 2439.95;
}
int buildMenu()
{
cout << "Welcome to the Devry Automated Teller Machine." << endl;
cout << "----------------------------------------------" << endl;
cout << endl;
cout << "1. Check balance." << endl;
cout << "2. Make withdrawal." << endl;
cout << "3. Make deposit." << endl;
cout << "4. View account information." << endl;
cout << "5. View statement." << endl;
cout << "6. View bank information." << endl;
cout << "7. Exit." << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
return 0;
}
int processAnswer(int answer)
{
double CurrBal = 2439.95;
double NewBal = 0.00;
switch (answer)
{
case '1':
cout << "Your account balance is " << CurrBal << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
break;
case '2':
cout << "How much would you like to withdraw from your account?" << endl;
double withdraw;
cin >> withdraw;
NewBal = CurrBal - withdraw;
cout << "You withdrew $ " << withdraw << endl;
cout << "Your new account balance is $ " << NewBal << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
break;
case '3':
cout << "How much would you like to deposit to your account?" << endl;
double deposit;
cin >> deposit;
NewBal = CurrBal + deposit;
cout << "You deposited $ " << deposit << endl;
cout << "Your new account balance is $ " << NewBal << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
break;
case '4':
cout << "Name: John Worley" << endl;
cout << "Account Number: 1234554321" << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
break;
case '5':
cout << "1/11/11 - McDonald's - $6.27" << endl;
cout << "1/15/11 - Kwik Trip - $34.93" << endl;
cout << "2/28/11 - Target - $124.21" << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
break;
case '6':
cout << "Devry Bank, established 2011" << endl;
cout << "(123) 456-7890" << endl;
cout << "12345 1st. St." << endl;
cout << "Someplace, NJ. 12345" << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
break;
case '7':
cout << "Thank you for using Devry Bank's Automated Teller Machine." << endl;
cout << "Good-bye" << endl;
break;
default:
cout << "Invalid selection." << endl;
cout << endl;
cout << "Please make a selection from the above menu." << endl;
break;
return answer;
}
}
TestMenu.cpp
Code:
#include <iostream>
#include <iomanip>
#include "MenuBuilder.h"
using namespace std;
int main()
{
MenuBuilder transaction;
int answer = 0;
while (answer != 7)
{
transaction.buildMenu();
cin >> answer;
transaction.processAnswer(answer);
}
system("pause");
return 0;
}
I feel like I'm overlooking something simple, but I just don't see it.
Anyone have any thoughts??
Thanks.