I need to add exception handling to this but unsure how i would go about this. I need to make sure the user is only allowed to input numerical values and not strings or negative numbers. Telling them "Sorry, that is not a valid numerical value. Please try again. Offering at least 500 FG for the help or more depending how clean you can input the error handling and explain what you did
Code
#include "math.h"
#include <iostream>
using namespace std;
int loanAmount; //amount of the loan
double loanInterest; // the loan interest rate
int loanYears; //years of the loan
int loanTerm = loanYears; //loan term in months
double loanPay; //variable for outputting the payment
int main()
{
cout<<"Enter Loan Amount";
cin>>loanAmount;
cout<<"Enter Loan Interest";
cin>>loanInterest;
cout<<"Enter Loan Years";
cin>>loanYears;
cout<<"Loan Term (months)";
loanPay = (loanAmount * loanInterest) / (1 - pow(1+loanInterest,-loanYears)); //Formula to figure mortgage payment amount
cout<< "Your Monthly Payment Amount is: $"<< loanPay; //prints out monthly payment amount
return 0;
}