Tuesday, July 22, 2014

Using Double in Java

import java.util.Scanner;
public class abejeroact11 {
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
String name;
int p;
int ppy;
int noy;
double ir;
System.out.println("Enter the name of Loan");
name = input.next(); //accept string
System.out.println("Enter the value for Principal");
p = input.nextInt();
System.out.println("How many times you're going to pay per year?");
ppy = input.nextInt();
System.out.println("How many years you're going to pay for that?");
noy = input.nextInt();
System.out.println("What is the Interest Rate?");
ir = input.nextDouble();
double ps = ir * (p / ppy) /1 - ((ir / ppy) + 1) * ppy * noy;
System.out.println(name+ "\tLoan");
System.out.println("Pay Per Year\n" +ppy);
System.out.println("Number of Years\n" +noy);
System.out.println("Interest Rate\n" +ir);
System.out.println("Payments\n" +ps);
}
}

No comments:

Post a Comment