Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4267978
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:58:22+00:00 2026-05-21T06:58:22+00:00

Could someone look at the portion of my code where I’m trying to void

  • 0

Could someone look at the portion of my code where I’m trying to void and close an account? This is what I want to achieve:

“2. Add a method void close() to your Account class. This method should close the current account by appending “CLOSED” to the account name and setting the balance to 0. (The account number should remain unchanged.) Also decrement the total number of accounts.”

When I tried to compile it, the program gave me an error about an identifier being expected. What am I missing?

//*******************************************************/
// Account.java
//
// A bank account class with methods to deposit to, withdraw from,
// change the name on, and get a String representation
// of the account.
//*******************************************************/

public class Account
{
  private double balance;
  private String name;
  private long acctNum;

  //----------------------------------------------
  //Constructor -- initializes balance, owner, and account number
  //----------------------------------------------
  public Account(double initBal, String owner, long number)
  {
    balance = initBal;
    name = owner;
    acctNum = number;
  }

  //----------------------------------------------
  // Checks to see if balance is sufficient for withdrawal.
  // If so, decrements balance by amount; if not, prints message.
  //----------------------------------------------
  public void withdraw(double amount)
  {
    if (balance >= amount)
       balance -= amount;
    else
       System.out.println("Insufficient funds");
  }
//----------------
//Track how many accounts
//----------------
    private static int numAccounts=0;
    {
        numAccounts++;
        }
    public static int getNumAccounts()
    {
        return numAccounts;
        }

  //----------------------------------------------
  // Adds deposit amount to balance.
  //----------------------------------------------
  public void deposit(double amount)
  {
    balance += amount;
  }

  //----------------------------------------------
  // Returns balance.
  //----------------------------------------------
  public double getBalance()
  {
    return balance;
  }

    //----------------------------------------------
  // Returns account number.
  //----------------------------------------------

  public long getAcctNumber()
  {
    return acctNum;
  }

//----------------
//Void and close the accounts
//----------------

public void close(Account)
{
    balance = 0;
    name = "CLOSE";
    acctNum = number;
    numAccounts--;
     return Account;
     }


  //----------------------------------------------
  // Returns a string containing the name, account number, and balance.
  //----------------------------------------------
  public String toString()
  {
    return "Name: " + name + 
"\nAccount Number: " + acctNum +
"\nBalance: " + balance; 
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:58:23+00:00Added an answer on May 21, 2026 at 6:58 am

    public void close(Account) needs a variable name. The declaration says it takes an Account parameter, but you also need to give the parameter a name e.g. public void close(Account account).

    Note that I don’t think that makes much sense. Given an account object you should probably be able to close it, so perhaps you should reconsider whether that parameter makes sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone take a look at this code and find out what's wrong with
I'm wondering if someone could look over my code. I'm trying to pass a
Could someone show me a regular expression that would look through this document and
I have the following code and I was wondering if someone could look at
Could someone tell me what the units the SetTimeout(int) method in the ICriteria interface
Could someone supply some code that would get the xpath of a System.Xml.XmlNode instance?
Could someone recommend any good resources for creating Graphics User Interfaces, preferably in C/C++?
Could someone write-up a step by step guide to developing a C++ based plugin
Could someone please demystify interfaces for me or point me to some good examples?
Could someone explain to me in simple terms the easiest way to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.