SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 26 Mar 2018 My Price 10.00

import java.util.NoSuchElementException;

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);
 
    }
 
}

 

 

Attachments:

Answers

(5)
Status NEW Posted 26 Mar 2018 03:03 PM My Price 10.00

  ----------- He-----------llo----------- Si-----------r/M-----------ada-----------m -----------  ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------

Not Rated(0)