Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include <string>
- #include <iostream>
- #include <cstdlib> // to use system("cls") used to "clear screen"
- #include <limits> // to declare numeric limits
- using namespace std;
- // class constructor
- Menu::Menu(void)
- {
- }
- // class destructor
- Menu::~Menu(void)
- {
- }
- int Menu::getOption() // function to prompt user for interest rate input
- {
- std::string reply;
- // User prompted to enter interest rate
- // Repeat until user enters a valid response
- do{
- system("cls");
- cout << endl;
- cout << endl << "Please choose a term and interest input option: ";
- cout << endl << "\t\t1.) Enter your own term and interest values.";
- cout << endl << "\t\t2.) Select from a list of term and interest options.";
- cout << endl;
- cout << endl << "Option selected: ";
- cin >> reply;
- if(validate(reply, "0123456789") == true)
- {
- cstr = reply.c_str();
- menuChoice = atoi(cstr);
- repeat = false;
- if(menuChoice <= 0)
- {
- repeat = true;
- callError();
- }
- else {
- if(menuChoice >= 3)
- {
- repeat = true;
- callError();
- }
- else {
- repeat = false;
- }
- }
- }
- }while(repeat == true);
- return menuChoice;
- if (menuChoice == 1)
- {
- double getInterestRate() // function to prompt user for interest rate input
- {
- // initialize variables
- double interestRate;
- string reply;
- // User prompted to enter interest rate
- cout << endl;
- cout << endl << "Please enter the interest rate (%): ";
- cin >> interestRate;
- return interestRate;
- }
- int getTerm() // function to prompt user for loan term input
- {
- // initialize variables
- int term;
- string reply;
- // User prompted to enter loan term
- cout << endl;
- cout << endl << "Please enter the loan term (years): ";
- cin >> term;
- return term;
- }
- }
- else{
- if (menuChoice == 2)
- {
- do // do while loop to make menu selection
- {
- system("cls");
- cout << endl;
- cout << endl << "Please choose term and interest option: ";
- cout << endl << "\t\t1.) 7 years at 5.35%";
- cout << endl << "\t\t2.) 15 years at 5.50%";
- cout << endl << "\t\t3.) 30 years at 5.75%";
- cout << endl;
- cout << endl << "Option selected: ";
- getline(cin, reply);
- if(validate(reply, "0123456789") == true)
- {
- cstr = reply.c_str();
- option = atoi(cstr);
- repeat = false;
- if(option <= 0)
- {
- repeat = true;
- callError();
- }
- else {
- if(option >= 4)
- {
- repeat = true;
- callError();
- }
- else {
- repeat = false;
- }
- }
- }
- }while(repeat == true);
- return option;
- }
- }
- }
Errors:
c:\users\sunni\documents\visual studio 2005\projects\sunnimortgagecalculatorr3\sunnimortg agecalculatorr3\menu.cpp(31) : error C2660: 'Menu::validate' : function does not take 2 arguments
c:\users\sunni\documents\visual studio 2005\projects\sunnimortgagecalculatorr3\sunnimortg agecalculatorr3\menu.cpp(59) : error C2601: 'getInterestRate' : local function definitions are illegal
c:\users\sunni\documents\visual studio 2005\projects\sunnimortgagecalculatorr3\sunnimortg agecalculatorr3\menu.cpp(57): this line contains a '{' which has not yet been matched
c:\users\sunni\documents\visual studio 2005\projects\sunnimortgagecalculatorr3\sunnimortg agecalculatorr3\menu.cpp(72) : error C2601: 'getTerm' : local function definitions are illegal
c:\users\sunni\documents\visual studio 2005\projects\sunnimortgagecalculatorr3\sunnimortg agecalculatorr3\menu.cpp(57): this line contains a '{' which has not yet been matched
c:\users\sunni\documents\visual studio 2005\projects\sunnimortgagecalculatorr3\sunnimortg agecalculatorr3\menu.cpp(100) : error C2660: 'Menu::validate' : function does not take 2 arguments
The following is the header file, in case that's where I've made the mistake:
Expand|Select|Wrap|Line Numbers
- class Menu
- {
- public:
- // base constructor
- Menu(void);
- // base destructor
- ~Menu(void);
- // base class methods
- int option;
- bool repeat;
- int menuChoice;
- int getOption();
- double getInterestRate();
- int getTerm();
- bool validate();
- const char *cstr;
- bool loop(void);
- void callError();
- };