Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ___________ __ .__ .__
- \_ _____/____ | | _| |_________ __ ______________ _______|__|
- | __) \__ \ | |/ / | \_ __ \ | \_ __ \__ \ \___ / |
- | \ / __ \| <| Y \ | \/ | /| | \// __ \_/ /| |
- \___ / (____ /__|_ \___| /__| |____/ |__| (____ /_____ \__|
- \/ \/ \/ \/ \/ \/
- */
- import java.util.Scanner;
- public class LoanCalc {
- private double loanAmount;
- private double rate;
- private int numberOfPayment;
- public LoanCalc(){
- loanAmount = 0;
- rate = 0;
- numberOfPayment=0;
- }
- public void setValue(){
- Scanner input = new Scanner(System.in);
- System.out.println("Insert Loan Amount: ");
- loanAmount = input.nextDouble();
- System.out.println("Insert Rates: ");
- rate = input.nextDouble();
- System.out.println("Insert Number Of Payment: ");
- numberOfPayment = input.nextInt();
- }
- public double getLoanAmount(){
- return loanAmount ;
- }
- public double getRate(){
- return rate;
- }
- public double getPayment(){
- return numberOfPayment;
- }
- public double getMonthly(){
- double monthly;
- monthly = (loanAmount+(numberOfPayment*((loanAmount *(rate/100)))))/(numberOfPayment * 12);
- return monthly;
- }
- public double getTotalPayment(){
- double total;
- total = getMonthly() * (numberOfPayment * 12);
- return total;
- }
- }
- class mainLoan{
- public static void main(String[] args){
- LoanCalc L1 = new LoanCalc();
- L1.setValue();
- System.out.println("Amount : "+L1.getLoanAmount());
- System.out.println("Rate : "+L1.getRate());
- System.out.println("Period : "+L1.getPayment());
- System.out.println("************************ : ");
- System.out.println("Monthly Payment : "+L1.getMonthly());
- System.out.println("Total Payment : "+L1.getTotalPayment());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement