Created
September 27, 2019 11:31
-
-
Save jtrent238/e01a8c52e28f36537affa99509899d00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
Welcome to GDB Online. | |
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, | |
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. | |
Code, Compile, Run and Debug online from anywhere in world. | |
*******************************************************************************/ | |
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
double loanAmount = 0; | |
double interestRate = 0; | |
double grossIncome = 0; | |
double monPay = 0; | |
double monPayEst = 0; | |
double totalIn = 0; | |
double totalInEst = 0; | |
double interestPercent = 0; | |
double payment = 0; | |
int loanDuration = 0; | |
int myPower = 0; | |
const int ZERO = 0; | |
const int ONE = 1; | |
const int TWENTY = 20; | |
const int THIRTY = 30; | |
printf("Enter the amount of the loan: " "\n"); | |
scanf("%.2lf", loanAmount); | |
if(loanAmount < ZERO) { | |
printf("Loan amount must be greater than $%.2lf" "\n", ZERO); | |
scanf("%.2lf", loanAmount); | |
} else { | |
printf("Enter the length of the loan (in years): " "\n"); | |
scanf("%d", loanDuration); | |
if(loanDuration <= ONE || loanDuration >= THIRTY) { | |
printf("Loan duration must be between %d year and %d years inclusive ", ONE, THIRTY); | |
scanf("%d", loanDuration); | |
} else {} | |
} | |
printf("Enter your monthly gross income: " "\n"); | |
scanf("%.2lf", grossIncome); | |
if(grossIncome < ZERO){ | |
printf("Monthly income must be greater than $%.2lf ", (double)ZERO); | |
scanf("%.2lf", grossIncome); | |
} | |
//myPower = pow((loanDuration - loanDuration) - loanDuration)); | |
payment = (loanAmount * interestRate) / (1 - pow((1 + interestRate), loanDuration)); | |
totalIn = (loanDuration * payment) - loanAmount; | |
printf("The monthly payment is: $%.2lf (~$%.2lf)" "\n", monPay, monPayEst); | |
printf("The total interest is: $%.2lf (~$%.2lf)" "\n", totalIn,totalInEst); | |
printf("The monthly payment is less than or equal to %.1lf%% of your gross monthly income." "\n", interestPercent); | |
printf("You are definitely approved for the loan!" "\n"); | |
printf("\n"); // Blank Line | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment