Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- * GROUP PROJECT *
- * LEADER: Jared Cabrera *
- * MEMBERS : Jezreel Salinas, Franco Miranda, Mauricio Alvarez *
- Arturo Morales, Dennis De Jesus *
- * @Date: November 16, 2017 *
- ******************************************************************************
- */
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <cstdlib>
- #include <windows.h>
- using namespace std;
- void loadmenu();
- int checkChoice(int&);
- void printPay(double&,double&,double&,double&,double&);
- void inputLoanAmount(double&);
- void inputInterest (double&);
- void inputMonthlyPayments (double&);
- void numPayments (double, double, double, int&);
- void loanPayments(double&, double&, double&, double&);
- int main()
- {
- int choice;
- double A, B, C, D, E;
- int F;
- HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(screen, 10);
- cout << "$$\\ $$$$$$\\ $$$$$$\\ $$\\ $$\\ $$$$$$\\ " << endl;
- cout << "$$ | $$ __$$\\ $$ __$$\\ $$$\\ $$ |$$ __$$\\" << endl;
- cout << "$$ | $$ / $$ |$$ / $$ |$$$$\\ $$ |$$ / \\__|" << endl;
- cout << "$$ | $$ | $$ |$$ __$$ |$$ \\$$$$ | \\____$$\\ " << endl;
- cout << "$$ | $$ | $$ |$$ | $$ |$$ |\\$$$ |$$\\ $$ |" << endl;
- cout << "$$$$$$$$\\ $$$$$$ |$$ | $$ |$$ | \\$$ |\\$$$$$$ |" << endl;
- cout << "\\________|\\______/ \\__| \\__|\\__| \\__| \\______/ " << endl;
- SetConsoleTextAttribute(screen, 15);
- cin.get();
- do{
- cout << "\n\n" << endl;
- loadmenu();
- cout << setw(10) << " " << "Enter your choice: ";
- cin >> choice;
- checkChoice(choice);
- switch(choice){
- case 1: {
- loanPayments(A,B,C,D);
- cout << setw(10) << " ";
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- printPay(A, B, C, D, E);
- cout << setw(10) << " ";
- system("pause");
- system("cls");
- break;
- }
- case 3: {
- inputLoanAmount(A);
- inputInterest(B);
- inputMonthlyPayments(C);
- numPayments(A, B, C, F);
- cout << setw(10) << " ";
- system("pause");
- system("cls");
- break;
- }
- case 4: {
- cout << setw(10) << " " << "Thank You For Using Me" << endl;
- exit(1);
- break;
- }
- }
- }while(choice != 4);
- return 0;
- }
- /******************************************************************************
- * loadmenu() function *
- * - This function loads and prints up the main menu *
- * *
- ******************************************************************************
- */
- void loadmenu(){
- cout << setw(10) << " " << "__________________________________" << endl;
- cout << setw(10) << " " << " LOAN AND SAVINGS PROGRAM " << endl;
- cout << setw(10) << " " << "__________________________________" << endl;
- cout << endl;
- cout << setw(10) << " " << "1. Find Monthly Loan Payments" << endl;
- cout << setw(10) << " " << "2. Print out a Loan Payback List" << endl;
- cout << setw(10) << " " << "3. Number of Payments" << endl;
- cout << setw(10) << " " << "4. EXIT Program" << endl;
- cout << setw(10) << " " << "__________________________________" << endl;
- cout << endl;
- }
- /******************************************************************************
- * checkChoice() function *
- * - This function check if the input choice is not less than 1 or 4 *
- * *
- ******************************************************************************
- */
- int checkChoice(int &choice){
- while (choice < 1 || choice > 4){
- cout << setw(10) << " " << "Re-Enter a Number 1-4: ";
- cin >> choice;
- }
- return (choice);
- }
- /******************************************************************************
- * printPay() function *
- * - This function print out a loan progression showing how much you have *
- * paid and what's left on the loan. *
- ******************************************************************************
- */
- void printPay(double &L, double &yInt,double &n,
- double &monthlyPayment, double &balance)
- {
- double mInt;
- cout << setw(10) << " " <<"Enter Loan Amount: ";
- cin >> L;
- cout << setw(10) << " " << "Enter Yearly Interest-Rate: ";
- cin >> yInt;
- cout << setw(10) << " " << "Enter the Number of Monthly Payments: ";
- cin >> n;
- cout << setw(10) << " " << "Enter Monthly Payment: ";
- cin >> monthlyPayment;
- cout << setw(10) << " " << "----------------------"
- << "---------------------------" << endl;
- cout << setw(10) << " " << "Payment No." << setw(4)
- << " " << "Total Paid" << setw(6) << " " << "Left to Pay" << endl;
- cout << endl;
- cout << setw(10) << " " << "----------------------"
- << "---------------------------" << endl;
- mInt = (yInt/100)/12;
- cout << fixed << setprecision(2);
- for(int i = 1; i <= n; i++){
- balance = (L*pow(1 + mInt, i)) - (monthlyPayment / mInt)
- *(pow(1 + mInt, i) - 1);
- cout << setw(13) << i << ":" << setw(18) << right
- << monthlyPayment*i << setw(18) << balance << endl;
- }
- cout << endl;
- }
- /******************************************************************************
- * inputLoanAmount() function *
- * - This function out a loan progression showing how much you have *
- * paid and what's left on the loan. *
- ******************************************************************************
- */
- void inputLoanAmount(double& loanAmount){
- cout << setw(10) << " " << "Enter Loan Amount: ";
- cin >> loanAmount;
- while (loanAmount < 0){
- cout << setw(10) << " " << "Enter Loan Amount: ";
- cin >> loanAmount;
- }
- }
- void inputInterest(double& interest){
- cout << setw(10) << " " << "Enter Monthly Interest: ";
- cin >> interest;
- while (interest < 0){
- cout << setw(10) << " " << "Enter Monthly Interest: ";
- cin >> interest;
- }
- interest = (interest / 100) / 12;
- }
- void inputMonthlyPayments(double& monthlyPayments){
- cout << setw(10) << " " << "Enter Monthly Payments: ";
- cin >> monthlyPayments;
- while (monthlyPayments < 0){
- cout << "Enter Monthly Payments: ";
- cin >> monthlyPayments;
- }
- }
- void numPayments(double A, double B, double C, int& F){
- cout << endl;
- F = (- log(1 - ((B * A) / C))) / (log(1 + B));
- cout << fixed << setprecision(2);
- cout << setw(10) << " " << "$" << C << " Requires " << F
- << " Payments" << endl;
- }
- void loanPayments(double& A, double& B, double& C, double& D)
- {
- cout << setw(10) << " " << "Enter Loan Amount: ";
- cin >> A;
- cout << setw(10) << " " << "Enter Interest Rate: ";
- cin >> C;
- cout << setw(10) << " " << "Enter Number of Payments: ";
- cin >> B;
- C = C / 100;
- D = ((C/12)*A)/(1-pow((1+C/12),-B));
- cout << setw(10) << " " << "Monthly Payment: $" << D << endl;
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement