TizzyT

CarLoans Psuedo-TizzyT

Feb 29th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. void main() {
  2. Print("Please input Loan Amount in Dollars (ex: 4500.00):");
  3. double amount = input.nextDouble();
  4. Print("Please input Interest Rate in Decimals (ex: 7.5% = 0.075):");
  5. double rate = input.nextDouble();
  6. Print("Please input Loan Duration in Months:");
  7. int months = (int)input.nextDouble();
  8. double monthlyInt = MonthlyInterest();
  9. double monthlyPay = MonthlyPayment();
  10. PrintInfo(amount, rate, months, monthlyPay);
  11. }
  12. double MonthlyInterest(double annualInterest) {
  13. return annualInterest / 12;
  14. }
  15. double MonthlyPay(double amount, double monthlyInterest, int months) {
  16. return (MonthlyInterest * Amount) / (1 - (1 + MonthlyInterest) ^ (Months * -1));
  17. }
  18. void PrintInfo(double borrowed, double annual, int months, double monthlyPay) {
  19. Print("Amount Borrowed ");
  20. Print("Annual Interest Rate ");
  21. Print("Length of Loan ");
  22. Println("Monthly Payment")
  23. Printf("%15.2f%23.3f%17d%17.2f", Borrowed, Annual, Months, MonthlyPay);
  24. }
Add Comment
Please, Sign In to add comment