08.12
Problem Specification:
This problem concerns the production of a java program that will calculate repayments on a student loan for a single year. Repayments are based upon the ex-student’s income and 3% interest that will be added to the loan every year by HM Government (nice people).
NOTE: You are required to also submit a flow chart and pseudo code to your tutor!
Method
1.First prompt and read the 2 inputs (loan and wages), store them in “double” variables.
2.Now calculate the net income by subtracting 10,000 pounds from the wages (that is the free threshold amount which you can keep and will not be used for repaying the loan).
3.Add 3% interest to the loan amount.
4.Finally calculate the new balance of the loan by subtracting the 9% deductions (calculated in step 2. above) from the current loan balance.
Here are three examples that show how the system works:
Example 1Example 2Example 3
Earned income£13,000£9,000£12,000keyboard input 1
Less threshold£10,000£10,000£10,000
Net income£3,000Nil£2,000output in response to input 1
Deductions 9%£270Nil£180
Loan£4,000£8,000£2,000keyboard input 2
Interest 3%£120£240£60 output in response to input 2
New balance£3,850£8,240£1,880
Typical Input / output
Input:
Enter total amount of student loan taken: 4000
Enter anticipated income: 13000
Corresponding Output:
Loan taken out: 4000, anticipated income 13000
Total plus interest: 4120
Amount Re-paid: 270
New balance: 3850
any help Please
——————————————————————————————-
import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;
public class MortgageCalculator2
{
static int months = 360;
static double rate = .0575;
public static void main(String[] args) throws IOException
{
// declare variables
double orignialLoan = 200000;
double newLoan = 200000;
String str = “”;
double payment;
double loanPayment = 0;
double interestPayment = 0;
int i;
// print to display monitor
System.out.println(”\t McBride Mortgage Payment Calculator”);
System.out.println();
System.out.println(”\t $200,000.00 Loan”);
System.out.println();
System.out.println(”\t at 5.75% for 30 year term”);
Scanner input = new Scanner(System.in);
System.out.println();
DecimalFormat twoDigits = new DecimalFormat(”$##,###.##”);// Format how it will be displayed.
// For Statement.
for (i = 1; i <= months; i ++)
{
orignialLoan = newLoan;
double interest = getInterest (rate); // Interest rate for the month.
payment = getPayment (interest, orignialLoan); // Payment per month.
newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
interestPayment = payment - loanPayment;// Amount of monthly interest.
// Print to display moniter.
System.out.println("The monthly payment on " + twoDigits.format(orignialLoan) + " at 5.75% rate is " + twoDigits.format(payment));
System.out.println();
System.out.println("New Balance " + twoDigits.format(newLoan));
System.out.println("Loan Payment " + twoDigits.format(loanPayment));
System.out.println("Interest Payment " + twoDigits.format(interestPayment));
if (i % 3 == 0){
System.out.println("Continue? (Y or N)");
str = input.nextLine();
if(str.equals("N") || str.equals("n"))
System.exit(0);
}
}
} // End For
} // end of main
// Get Interest Method
public static double getInterest(double rate)
{
double interest = rate / (12 * 100);
return interest;
} // End of Interest Method
// Get Payment Method
public static double getPayment (double interest, double orignialLoan)
{
double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
return payment;
} // End of Payment Method
// Get New Loan Amount
public static double getNewLoan (double interest, double payment, double orignialLoan)
{
double newLoan = orignialLoan * (1 + interest) - payment;
return newLoan;
} // End New Loan Amount
} // end program
My Question is how to add main method to it I start again i m lost .2.Now calculate the net income by subtracting 10,000 pounds from the wages
-----------------------------------------
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Assignment2 {
private static final Scanner scan = new Scanner(System.in);
public static void main (String args[]) throws IOException
{
double loan_amount, anticipated, interest_rate, interest_rate_month,interest,unpaid_amount;
double installment, principal;
double interests_rate = 3;
int loan_period = 12;
int payment_no = 0;
int a;
System.out.print("Enter total amount of student loan taken: "); //Input of loan amount
loan_amount = scan.nextDouble();
System.out.print("Enter anticipated income: ");
anticipa
done so far
----------------------------------
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Assignment2 {
private static final Scanner scan = new Scanner(System.in);
public static void main (String args[]) throws IOException
{
double loan_amount, anticipated, interest_rate, interest_rate_month,interest,unpaid_amount;
double installment, principal;
double interests_rate = 3;
int loan_period = 12;
int payment_no = 0;
int a;
System.out.print("Enter total amount of student loan taken: "); //Input of loan amount
loan_amount = scan.nextDouble();
System.out.print("Enter anticipated income: ");
anticipated = scan.nextDouble();
interest_rate_month = interests_rate / (loan_period*100);
not enuf room here to post ?????
Bernard

Kathleen
OK, you’ve given us the background, but what is your question?