case 'C':
cout << "\nYou selected a 30 year loan term at 5.75 percent\n" ;
mpaymentAmount = (mloanAmount*((minterestRate[2]/100)/12))/(1-(pow(1+((minterestRate[2]/100)/12),(-(mterm[2]*12))))); //Calculates monthly payment
cout << "\n\n\nYour Monthly Payment Amount Will Be: " << " $" << mpaymentAmount << "\n\n"; //print out result
mortEnt::amort( );
while(loop() == true);
}
}
void mortEnt::amort( )
{
cout << "\n\n\nPress <Enter> key to view your amortization schedule.\n\n";
cin.get();
cin.get() does not work passing from one source to another or at least not how I have wrote it. I basically have outputs coming from the four functions above (I have posted parted of one) to input into this function to be used for an amortization table. Any advice would be greatly appreciated.
Er, what is this code supposed to do? Not only do i see 2 '}' and only one '{' (which comes after the others), so it doesn't work at all. Also you have an empty loop (while(loop() == true);) which cannot terminate except loop() somehow changes a static state or is a function object changing a functor state upon operator() usage. So again, what is that supposed to be?
cin.get() does not work passing from one source to another
Here is the whole .cpp. What I mean is that for some reason I am getting characters instead of numbers for an output. Help?
//mortEnt.cpp file
#include "mortEnt.h"
#include <iostream>
using namespace std;
mortEnt::mortEnt( )
{
cout << endl
<< "\t**********************************************" << endl
<< "\t Walt's Mortgage Calculator " << endl
<< "\t This mortgage calculator determines " << endl
<< "\t the monthly payment after you enter " << endl
<< "\t the required information when prompted. " << endl
<< "\t**********************************************" << endl
<< endl;
cout<< "\nPlease make a selection\n"<< endl
<< "(A) Enter your interest and loan term." << endl
<< "(B) Select a predetermined interest and loan term." << endl
<< endl;
char menu = ' ' ;
cout << "\nPlease select an option above by choosing the letter in parenthesis: " ;
cin >> menu ;
menu = toupper(menu) ; // case
system("cls");
switch(menu)
{
case 'A':
mortEnt::input( );
break;
cout << "\nPlease enter the loan amount and press ENTER: " ; //prompt
cin >> mloanAmount;
cout << endl;
cout << "\n\nSelect a term and interest rate:\n" << endl
<< "(A) 07 year loan mterm at 5.35 percent" << endl
<< "(B) 15 year loan mterm at 5.50 percent" << endl
<< "(C) 30 year loan mterm at 5.75 percent" << endl
<< endl;
char menu = ' ' ;
cout << "\nPlease select an option above by choosing the letter in parenthesis: " ;
cin >> menu ;
menu = toupper(menu) ; // case
system("cls");
bool loop() //Allows user to reenter the program to enter new data
{
char reply;
bool loop;
bool repeat = false;
do // Ask if user would like to calculate another payment amount
{
system("cls");
cout << endl << endl;
cout << "\nWould you like to calculate another payment amount? (Y/N):"; //Does user want to reenter data?
cin >> reply;
reply = toupper(reply);
if(reply == 'Y' || reply == 'N')
{
loop = false;
switch(reply)
{
case 'Y': repeat = true; //Yes proceed to clear screen and restart
system("cls");
mortEnt( );
break;
case 'N': repeat = false; //No proceed to exit program
exit(0);
break;
}
}
else
{
loop = true;
cout << "\n\nPlease enter 'Y' or 'N' ONLY!\n\n"; //invalid data entered by user
}
}
while(loop == true);
cin.clear();
cin.get();
return repeat;
}
// mortEnt.h file
#ifndef mortEnt_h
#define mortEnt_h
#include <iostream> //Basic input and output library
#include <iomanip> //Basic input and output manipulations library
#include <cmath> //Declares a set of functions to compute common mathematical operations and transformations
#include <cstdlib> //Uses system("cls") used to "clear screen"
#include <math.h> // for pow() function