Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- Print("Please input Loan Amount in Dollars (ex: 4500.00):");
- double amount = input.nextDouble();
- Print("Please input Interest Rate in Decimals (ex: 7.5% = 0.075):");
- double rate = input.nextDouble();
- Print("Please input Loan Duration in Months:");
- int months = (int)input.nextDouble();
- double monthlyInt = MonthlyInterest();
- double monthlyPay = MonthlyPayment();
- PrintInfo(amount, rate, months, monthlyPay);
- }
- double MonthlyInterest(double annualInterest) {
- return annualInterest / 12;
- }
- double MonthlyPay(double amount, double monthlyInterest, int months) {
- return (MonthlyInterest * Amount) / (1 - (1 + MonthlyInterest) ^ (Months * -1));
- }
- void PrintInfo(double borrowed, double annual, int months, double monthlyPay) {
- Print("Amount Borrowed ");
- Print("Annual Interest Rate ");
- Print("Length of Loan ");
- Println("Monthly Payment")
- Printf("%15.2f%23.3f%17d%17.2f", Borrowed, Annual, Months, MonthlyPay);
- }
Add Comment
Please, Sign In to add comment