You are on page 1of 3

ITSS 3211 Introduction to Programming

Dr. Nassim Sohaee


Fall 2015

Student name: Adam Melaku


Course Number: ITS 3211
Section Number: 003
Due Date: 11/15/2015
Important notes:
None.
Pledge:
I understand that the consequences of committing any act of academic dishonesty
can include a failing grade for the assignment, failure in the class as a whole, and
even expulsion from the university. I will not plagiarize or cheat.
Analysis:
I had to design a java program that would ask the user to enter a loan
amount and a time period in number of years and then display the
monthly and total payments for each interest rate (from 5%-8%,
incrementing by .125% each line)
Design:
First I had to import a scanner and then I began to add the variables that would be
needed to hold the data inputted by the user. I would then ask the user to input the
loan amount (loanAmount) and the loan period in number of years (numberofYears).
Afterward a loop will be created to help display all the different lines of output
needed (lines must display the monthly and total payments for each interest rate
ranging from 5% to 8%).

Coding:
///////////////////////////////////////
////////////////////////////////////////
//
ALL STUDENTS COMPLETE THESE SECTIONS
// Title:
Project1
// Files:
java.util.Scanner
// Semester:

//Fall 2015
//
// Author:
Adam Melaku
//Email:
Aam131630
// CS Login:
Aam131630
// Lecturer's Name: Professor Sohaee
// Course Section:
003
//
//////////////////// STUDENTS WHO GET HELP FROM OTHER THAN THEIR
PARTNER //////
//
fully acknowledge and credit all sources of help,
//
other than Instructors and TAs.
//
// Persons:
None.
//
// Online sources:
None.
//////////////////////////// 80 columns
wide //////////////////////////////////
import java.util.Scanner;
public class loansProject {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double loanAmount;
double numberofYears;

//declare variables

System.out.println("Enter the loan amount: ");


//ask user for loan amount
loanAmount = input.nextDouble();
System.out.println("Enter the loan period in number of years: ");
//ask user for loan period(in years)
numberofYears = input.nextDouble();
System.out.printf("%-16s%-17s%-20s%n", "Interest Rate", "Monthly
Payment", "Total Payment");
//set up output with proper spacing
for (double interestRate = 0.05; interestRate < 0.08125;
interestRate += 0.00125) // introduction of loop
{
double monthlyPay = (loanAmount * (interestRate / 12))/(1 (Math.pow(1 / (1 + (interestRate / 12)), numberofYears * 12)));
//display
new variables and how to calculate them
double totalPay = monthlyPay * numberofYears * 12;
System.out.printf("%3.3f%%%10s%-17.2f%-15.2f%n",
interestRate * 100, "", monthlyPay, totalPay);
//set up spacing for
displayed outputs
}
}
}

Testing:
There were initial syntax errors when I first ran the program but it was easily
corrected when I went back and saw I forgot a letter on certain lines (human error).
When everything was done the program ran properly but I felt like I needed to work
on the spacing of my output for the title lines (Interest Rate, Monthly Rate, and Total
Payment) After worked on my spacing I was satisfied with my program.

You might also like