Java Last Exercise
Java Last Exercise
intRate + 1; } } ________________________________________________________________________________ public class PersonalLoan extends Loan{ public PersonalLoan(int h, String j, double k, int l){ super(h,j,k,l); super.intRate = super.intRate + 2; } } ________________________________________________________________________________ _____ public interface LoanConstants{ final final final final final } ________________________________________________________________________________ _________ public abstract class Loan implements LoanConstants { private String name; private double amount; public double intRate=10.0; private int num,term; public Loan(int h, String j, double k, int l){ num = h; name = j; amount = k; term = l; if(loanAmount > MAX_LOAN_AMOUNT){ System.out.println("EWWOW"); amount = 0.0; } if(term != SHORT_TERM && term != MEDIUM_TERM && term != LONG_TERM){ System.out.println("EWWOW"); term = 1; int SHORT_TERM = 1; int MEDIUM_TERM = 3; int LONG_TERM = 5; String COMPANY_NAME = "Sanchez and Construction Loan Co."; double MAX_LOAN_AMOUNT = 100000.00;
} } public String toString(){ String e = "Loan Number = " + loanNumber + "Costumer Last Name = " + cLastName + "Loan Amount = " + loanAmount + "Interest Rate = " + intRate + "Term = " + term + "Total Amount Owed: " + (amount + (amount * (intRate/100))); return e; } } ________________________________________________________________________________ _____________________ import java.util.Scanner; public class CreateLoans { public static void main(String[] args){ Scanner s = new Scanner(System.in); int num,term,choice; String name; double amount; Loan[] w = new Loan[5]; for(int i=0;i<MAX_SIZE;i++){ System.out.println("Choose Loan Type:1 Business Loan 2 Personal Loan"); choice = s.nextInt(); if(choice == 1){ System.out.print("\nEnter Loan Number: " ); num = s.nextInt(); System.out.print("Enter Last Name: "); s.nextLine(); name = s.nextLine(); System.out.print("Enter Loan Amount: "); amount = s.nextDouble(); System.out.print("Enter Number of Terms: "); term = s.nextInt(); w[i] = new BusinessLoan(num,name,amount, term); } else if(choice == 2){ System.out.print("\nEnter Loan Number: " ); num = s.nextInt(); System.out.print("Enter Last Name: "); s.nextLine(); name = s.nextLine(); System.out.print("Enter Loan Amount: "); amount = s.nextDouble(); System.out.print("Enter Number of Terms: "); term = s.nextInt();
w[i] = new PersonalLoan(num,name,amount, term); } else System.out.println("EWWOW! MUWST BEW WONE OW TWO"); } for(int i=0;i<w.length;i++){ System.out.println(w[i].toString()); } }