title: Resource leak input is never closed - where/when do i close and how?
body: <p>I tried closing it but i'm not sure where to put the input.close();, im really new to all this and asking my professors risks me losing points. Also i'm not sure if i should keep the second to last system.out monthly payment is, or get rid of it. Does it even make sense with the rest of my code?</p>
  
  <pre><code>import java.util.Scanner;
  public class Project2 {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          Scanner input = new Scanner(System.in);
  
          //Yearly interest rate
          System.out.print("Enter annual interest rate, for example 0.5, no percent sign:");
          double annualInterestRate = input.nextDouble();
  
          //Monthly interest rate
          double monthlyInterestRate = annualInterestRate / 1200;
  
          //Number of years
          System.out.print("Enter number of years, for example 5: ");
          int numberOfYears = input.nextInt() ;
  
          //Loan amount
          System.out.print("Enter investment amount, for example 145000.95: ");
          double loanAmount = input.nextDouble();
  
          //Calculate payments
          double monthlyPayment = loanAmount * monthlyInterestRate / (1
                  - 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12));
          double totalPayment = monthlyPayment * numberOfYears * 12;
  
          System.out.println("The monthly payment is " + 
          (int) (monthlyPayment * 100) / 100.0);
  
          System.out.println("Accumulated value is " +
          (int) (totalPayment * 100) / 100.0);
  </code></pre>