Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Answer this problem in java: Assignment Description: To simulate a real world pr

ID: 3723388 • Letter: A

Question

Answer this problem in java:

Assignment Description: To simulate a real world programming project, a bank manager gives you a general description of what is needed by the bank (your client): Big12 Bank Midwest needs software (i.e. a program) that can be used to figure monthly payment and the total amount to be paid on various mortgage (i.e. house) loans. Program should be flexible enough to either allow a bank officer to enter in all the input or use a special advertised promotion where the customer can get a $150,000 house loan for 25 years at the annual rate of 3.95%. The program should provide a menu that allows the bank officer to choose between the two. Program should continue until the user decides to end the input. The program will display all output to the screen AND write the output to a text file in the following format: Customer Number: Loan Amount: S Loan Term: Interest Rate: % Monthly Payment: S Total Payment: S (to 2-decimals) (to 2-decimals) (to 2-decimals) Use modular programming techniques (i.e. methods) to develop a solution to the program requested.

Explanation / Answer

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.lang.Math.pow;

public class MortageCalculation {

   public static void main(String[] args){
       int choice;
       String fileName;
       Scanner sc = new Scanner(System.in);
      
       System.out.println("Big12 Bank Midwest Mortage Calculation Software");
       System.out.println("Developed by <Student Name Goes Here");
      
       System.out.println("Please choose from the following choices below:");
       System.out.println("1) Promotional Loan ($150,000 @ 3.95% for 25 years");
       System.out.println("2) Unique loan (enter in loan values)");
       System.out.println("Quit (Exit the Program)");
       System.out.println("Please enter your selection (1-3)");
       choice = sc.nextInt();
       while(choice<=1 && choice >=3){
           System.out.println("Invalid Choice.Please select 1,2 or 3");
           choice = sc.nextInt();
       }
       switch (choice)
{
case 1 :
   System.out.println("PROMOTIONAL LOAN...");
   System.out.println("Customer Number: "+getCustomerNo());
   System.out.println("Loan Amount: $150,000");
   System.out.println("Loan Term: 25 years");
   System.out.println("Interst Rate: 3.95%");
   double mp = calcMonthlyPayment(150000,3.95,25);
   double tp = calcTotalPayment(mp,getLoanTerm());
   System.out.print("Monthly Payment: ");
   displayPayments(mp);
   System.out.print("Total Payment: ");
   displayPayments(tp);
   writeToFile(getCustomerNo(),150000,25,3.95,mp,tp);
break;
case 2 :
   System.out.println("Customer Number: "+getCustomerNo());
   System.out.print("Loan Amount: ");
   displayPayments(getLoanAmount());
   System.out.println("Loan Term: "+getLoanTerm());
   System.out.println("Interst Rate: "+getInterestRate());
   double mp1 = calcMonthlyPayment(getLoanAmount(),getInterestRate(),getLoanTerm());
   double tp1 = calcTotalPayment(mp1,getLoanTerm());
   System.out.print("Monthly Payment: ");
   displayPayments(mp1);
   System.out.print("Total Payment: ");
   displayPayments(tp1);
   writeToFile(getCustomerNo(),getLoanAmount(),getLoanTerm(),getInterestRate(),mp1,tp1);
break;
case 3 :
System.exit(0) ;   
default :
break;
}
      
   }
   public static String getCustomerNo(){
       String cust_no;
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter the customer number (6 characters and/or digits)");
   cust_no = sc.nextLine();
   String pattern= "^[a-zA-Z0-9]*$";
while(!cust_no.matches(pattern)){
   System.out.println("Valid customer number are 6 characters and/or digits");
   System.out.println("Please re-enter valid Customer number: ");
   cust_no = sc.nextLine();
}
       return cust_no;
   }
   public static double getLoanAmount(){
       double amt;
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter loan amount without $ or commas (Ex:75500): ");
   amt = sc.nextDouble();
while(!(amt<50000 && amt>1000000)){
   System.out.println("Valid Loan Amounts are $50000-$1000000 ");
   System.out.println("Please re-enter loan amount without $ or commas (Ex:75500): ");
   amt = sc.nextDouble();
}
       return amt;
   }
   static double getInterestRate(){
       double r;
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter yearly interst rate (Ex: 5.25)");
   r = sc.nextDouble();
while(!(r>=2 && r<=9)){
   System.out.println("Valid Interst Rates are 2% - 9%");
   System.out.println("Please re-enter valid interest rate: Ex 5.25 ");
   r = sc.nextDouble();
}
       return r;
   }
   static double getLoanTerm(){
       double t;
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter loan term in years: ");
   t = sc.nextDouble();
while(!(t==15||t==20||t==25||t==30)){
   System.out.println("Valid Loan terms are 15,20,25 or 30 ");
   System.out.println("Please re-enter loan term: ");
   t = sc.nextDouble();
}
       return t;
   }
   static double calcMonthlyPayment(double P,double I,double N ){
       double MP;
       double r =pow((1+I),N);
       double t = P*I*r;
       MP = t/(r+1);
       return MP;
      
   }
   static double calcTotalPayment(double MP,double N){
       double TP;
       TP = MP*12*N;
       return TP;
      
   }
   static void displayPayments(double P){
       DecimalFormat formatter = new DecimalFormat("#,###.00");

       System.out.println("$"+formatter.format(P));
      
   }
   //Write to a file
   static void writeToFile(String c,double a,double y,double i,double mp,double tp){
       Scanner sc = new Scanner(System.in);
       System.out.println("Please enter the file name to be used for output (without .txt)");
       String fileName = sc.nextLine();
       try {
           PrintWriter out = new PrintWriter(new File(fileName));
           DecimalFormat formatter = new DecimalFormat("#,###.00");
   out.println("Customer Number: "+getCustomerNo());
   out.println("Loan Amount: $"+formatter.format(a));
   out.println("Loan Term: "+ y +"years");
   out.println("Interst Rate: "+i);
   out.print("Monthly Payment: ");
   out.println("$"+formatter.format(mp));
   out.print("Total Payment: ");
   out.println("$"+formatter.format(tp));
       } catch (FileNotFoundException e) {
           // TODO Auto-generated catch block
           System.out.println("File Not Found");
       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote