I'm trying to get a java program to call a file to run it with the script and i can't seem to get it to call the file. Is there a particular thing i'm suppose to do??
Loan Main Method
Â
package week7assignment;
Â
import java.io.File;
import java.io.FileNotFoundException;
import java.text.DecimalFormat;
import java.util.NoSuchElementException;
import java.util.Scanner;
Â
/**
 *
 * @authorÂ
 */
public class Loan {
Â
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
Â
    //setting format for money
    DecimalFormat money = new DecimalFormat("$#,##0.00");
Â
    //instatiating new CarLoan object
    CarLoan newLoan = new CarLoan(18875.0);
    System.out.println(newLoan);
Â
    try {
Â
      int numb = 0;//variable for number of payments
      double totPaid = 0;//variable for total amount paid
      Scanner pay = new Scanner(new File("Payments.txt"));//reading in file
      while (pay.hasNext()) {
        numb++;
Â
        double payment = pay.nextInt();//reading each line
        totPaid += payment;
Â
        newLoan.payment(payment);//passing information to payment method
        System.out.println("\n Payment " + numb + " is " + money.format(payment)
            + ". Remaining balance is: " + newLoan);
Â
        System.out.println("\t Total of payments made is : " + money.format(totPaid));
      }
      pay.close();
    } catch (FileNotFoundException fnfe) {
      System.out.println("File not found");
    } catch (NoSuchElementException nsee) {
      System.out.println("File not found");
    } catch (IllegalStateException ise) {
      System.out.println("File not found");
    }
  }
Â
}
Â
Â
Bank Account Class
Â
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package week7assignment;
Â
import java.text.DecimalFormat;
Â
/**
 *
 * @authorÂ
 */
public class BankAccount {
Â
  public final DecimalFormat money = new DecimalFormat("$#,##0.00");
  protected double balance;
Â
  public BankAccount() {
    balance = 0.0;
  }
Â
  public BankAccount(double startBalance) {
    deposit(startBalance);
  }
Â
  public double getBalance() {
    return balance;
  }
Â
  public void deposit(double amount) {
    if (amount >= 0.0) {
      balance += amount;
    } else {
      System.err.println("Loan Balance must be positive!");
    }
  }
Â
  public void payment(double amount) {
    if (amount >= 0.0 && amount <= balance) {
      balance = balance - amount;
    } else {
      System.err.println("Payment amount must be positive, and "
          + "cannot be grater than balace!");
    }
Â
  }
Â
  @Override
  public String toString() {
    return ("Balance on car loan is " + money.format(balance));
  }
Â
}
Â
Car Loan Class
Â
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package week7assignment;
Â
/**
 *
 * @authorÂ
 */
public class CarLoan extends BankAccount {
Â
  public CarLoan() {
    super();
Â
  }
Â
  public CarLoan(double startBalance) {
    super(startBalance);
Â
  }
Â
}
Â
Â