Question

Unable to find out why am I getting: Account.java:85: error: reached end of file while parsing...

Unable to find out why am I getting: Account.java:85: error: reached end of file while parsing

import java.util.*;

class Account{

private int id;

private double balance;

private double annualInterestRate;

private Date dateCreated;

public Account()

{

id = 0;

balance = 0;

annualInterestRate = 0;

dateCreated = new Date();

}

public Account(int id1, double balance1)

{

id =id1;

balance = balance1;

dateCreated = new Date();

}

public void setId(int id1)

{

id=id1;

}

public void setBalance(double balance1)

{

balance = balance1;

}

public void setAnnualInterestRate(double rate)

{

annualInterestRate = rate/100;

}

public int getId()

{

return id;

}

public double getBalance()

{

return balance;

}

public double getAnnualInterestRate()

{

return annualInterestRate;

}

public Date getDate()

{

return dateCreated;

}

public double getMonthlyInterestRate()

{

return annualInterestRate/12;

}

public double getMonthlyInterest()

{

return getMonthlyInterestRate()*balance;

}

public void withdraw(double amount)

{

if(amount . balance)

{

System.out.println("Entered amount "

+ "is greater than balance.");

System.exit(0);

}

balance = balance - amount;

}

public void deposit(double amount)

{

balance = balance + amount;

}

}

public class AccountTest {

public static void main(String[] args) {

{

Account a = new Account(1122, 20000);

a.setAnnualInterestRate(4.5);

a.withdraw(2500);

a.deposit(3000);

System.out.println("Balance in the account is:"

+ " $" + a.getBalance());

System.out.println("Monthly interest is: $"

+ a.getMonthlyInterest());

System.out.println("The account created date: "

+ a.getDate().toString());

}

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.*;

class Account {
    private int id;
    private double balance;
    private double annualInterestRate;
    private Date dateCreated;

    public Account() {
        id = 0;
        balance = 0;
        annualInterestRate = 0;
        dateCreated = new Date();
    }

    public Account(int id1, double balance1) {
        id = id1;
        balance = balance1;
        dateCreated = new Date();
    }

    public void setId(int id1) {
        id = id1;
    }

    public void setBalance(double balance1) {
        balance = balance1;
    }

    public void setAnnualInterestRate(double rate) {
        annualInterestRate = rate / 100;
    }

    public int getId() {
        return id;
    }

    public double getBalance() {
        return balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public Date getDate() {
        return dateCreated;
    }

    public double getMonthlyInterestRate() {
        return annualInterestRate / 12;
    }

    public double getMonthlyInterest() {
        return getMonthlyInterestRate() * balance;
    }

    public void withdraw(double amount) {
        if (amount > balance) {
            System.out.println("Entered amount " + "is greater than balance.");
            System.exit(0);
        }
        balance = balance - amount;
    }

    public void deposit(double amount) {
        balance = balance + amount;
    }
}

class AccountTest {
    public static void main(String[] args) {
        Account a = new Account(1122, 20000);
        a.setAnnualInterestRate(4.5);
        a.withdraw(2500);
        a.deposit(3000);
        System.out.println("Balance in the account is:" + " $" + a.getBalance());
        System.out.println("Monthly interest is: $" + a.getMonthlyInterest());
        System.out.println("The account created date: " + a.getDate().toString());
    }
}

Add a comment
Know the answer?
Add Answer to:
Unable to find out why am I getting: Account.java:85: error: reached end of file while parsing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The code is attached below has the Account class that was designed to model a bank account.

    IN JAVAThe code is attached below has the Account class that was designed to model a bank account. An account has the properties account number, balance, annual interest rate, and date created, and methods to deposit and withdraw funds. I need creat program using the 2 java programs.Create two subclasses for checking and savings accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn.I need to write a test program that creates objects of Account,...

  • Hello, I'm very new to programming and I'm running into a problem with the system.out.println function...

    Hello, I'm very new to programming and I'm running into a problem with the system.out.println function in the TestAccount Class pasted below. Account Class: import java.util.Date; public class Account {    private int accountId;    private double accountBalance, annualInterestRate;    private Date dateCreated;    public Account(int id, double balance) { id = accountId;        balance = accountBalance; dateCreated = new Date();    }    public Account() { dateCreated = new Date();    }    public int getId() { return...

  • Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default...

    Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default values for balance #and annual interest rate are 100 and e, respectively). #INITIALIZER METHOD HEADER GOES HERE #MISSING CODE def getId(self): return self._id def getBalance(self): #MISSING CODE def getAnnualInterestRate(self): return self.___annualInterestRate def setBalance(self, balance): self. balance - balance def setAnnualInterestRate(self,rate): #MISSING CODE def getMonthlyInterestRate(self): return self. annualInterestRate/12 def getMonthlyInterest (self): #MISSING CODE def withdraw(self, amount): #MISSING CODE det getAnnualInterestRate(self): return self. annualInterestRate def setBalance(self,...

  • (Enable the Account class comparable & cloneable) @ Create ComparableAccount class inheritanc...

    (Enable the Account class comparable & cloneable) @ Create ComparableAccount class inheritance from the Account class, and implemented the comparable and cloneable interfaces. Override the compareTo method to compare the balance of two accounts. Print the Account ID, balance and dataCreated information from the toString() method. Implements the cloneable interface and override the clone method to perform a deep copy on the dateCreated field. Write a driver program to create one array contains 5 ComparableAcccount objects (account #: 1001-1005, initial...

  • 9.7 (The Account class) Design a class named Account that contains: • A private int data...

    9.7 (The Account class) Design a class named Account that contains: • A private int data field named id for the account (default o). • A private double data field named balance for the account (default o). • A private double data field named annualInterestRate that stores the current interest rate (default o). Assume that all accounts have the same interest rate. • A private Date data field named dateCreated that stores the date when the account was created. •...

  • How do you write a test class that tests each of the setters and constructors to ensure that the appropriate exception is raised?(Note: sed. Recall that the setter method should be called in the constructor and the edits should not be in the setters, not

     /** * Write a description of class LoanTest here. * */public class Loan {  private double annualInterestRate;  private int numberOfYears;  private double loanAmount;  private java.util.Date loanDate;  /** Default constructor */  public Loan() {    this(2.5, 1, 1000);  }  /** Construct a loan with specified annual interest rate,      number of years and loan amount     */  public Loan(double annualInterestRate, int numberOfYears,double loanAmount){    if(loanAmount <= 0)    {        throw new IllegalArgumentException("loan must be greater than 0");       } ...

  • (The Account class) Design a class named Account that contains: A private int data field named...

    (The Account class) Design a class named Account that contains: A private int data field named id for the account (default 0). A private double data field named balance for the account (default 0). A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default...

  • If I enter a negative value the program throws an error and the withdrawal amount is...

    If I enter a negative value the program throws an error and the withdrawal amount is added to the balance please help me find why? public abstract class BankAccount { private double balance; private int numOfDeposits; private int numOfwithdrawals; private double apr; private double serviceCharge; //Create getter and setter methods public double getBalance() { return balance; } public void setBalance(double balance) { this.balance = balance; } public int getNumOfDeposits() { return numOfDeposits; } public void setNumOfDeposits(int numOfDeposits) { this.numOfDeposits =...

  • Design a class named BankAccount that contains: 1. A private int data field named accountId for...

    Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT