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

  • SEARCH
  • Home
  • 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 7518089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:39:21+00:00 2026-05-30T01:39:21+00:00

Modify class Account (attached in Blackboard) to provide • An integer class instant variable

  • 0

Modify class Account (attached in Blackboard) to provide
• An integer class instant variable accountNum to be the class number
(Don’t forget that you need to change the constructor).
• A method called debit that withdraws money from an Account. Ensure that
the debit amount does not exceed the Account’s balance. If it does, the
balance should be left unchanged and the method should print a message
indicating “Debit amount exceeded account balance.”
• In method getBalance(), add a line to print out the account number and
account balance, then in the Test program, you just need to type,
account1.getBalance(); instead of the printf statement.
AccountTest file has been modified already to test your new Accountclass, so you
do not need to change it.

here is my code for the Account Class

public class Account
{
    private double balance;
    public int accountNum;
    public int Account;
    public Account(double initialBalance, int accountN)
    {
        if ( initialBalance > 0.0 )
            balance = initialBalance;
            accountNum=accountN;
    }

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

    public void debit(double amount)
    {
        if (amount>=balance)
            System.out.println("Debit amount exceeded account balance."); 
        else
            balance-=amount;
    }

    public String getBalance()
    {
        return balance+" "+accountNum;
    } 
}

Here is the Code For The AccountTest class

import java.util.Scanner;

public class AccountTest
{
    // main method begins execution of Java application
    public static void main( String args[] ) 
    {
        Account account1 = new Account( 1, 50.00 ); // create Account object
        Account account2 = new Account( 2, -7.53 ); // create Account object

        // display initial balance of each object
        account1.getBalance();
        account2.getBalance();

        // create Scanner to obtain input from command window
        Scanner input = new Scanner( System.in );
        double depositAmount; // deposit amount read from user

        System.out.print( "Enter deposit amount for account2: " );
        depositAmount = input.nextDouble(); // obtain user input
        System.out.printf( "\nadding %.2f from account1 balance\n", depositAmount );
        account2.credit( depositAmount ); // add amount to account1

        // display balances
        account1.getBalance();
        account2.getBalance();

        // create Scanner to obtain input from command window
        input = new Scanner( System.in );
        double withdrawalAmount; // withdrawal amount read from user

        System.out.print( "Enter withdrawal amount for account1: " ); 
        withdrawalAmount = input.nextDouble(); // obtain user input
        System.out.printf( "\nsubtracting %.2f from account2 balance\n", withdrawalAmount );
        account1.debit( withdrawalAmount ); // subtract amount from account2

        // display balances
        account1.getBalance();
        account2.getBalance();
    } // end main
} // end class AccountTest

i cannot figure out what is missing please help thanks a bunch.

  • 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-30T01:39:22+00:00Added an answer on May 30, 2026 at 1:39 am

    You just have your Account constructor to accept a double and an int, in that order.

    So right after your main method you have

    Account account1 = new Account( 1, 50.00 );
    Account account2 = new Account( 2, -7.53 );
    

    When it should be

    Account account1 = new Account(50.00, 1);
    Account account2 = new Account(-7.53, 2);
    

    All methods and constructors in java will only work if you pass values exactly as they are in the method declaration. Generally every time you see a “cannot find symbol” error it’s this problem.

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

Sidebar

Related Questions

You have a class that many libraries depend on. You need to modify the
I have a class in C++ that I can't modify. However, that class holds
In short: is there some way I can modify a class definition such that
Is there a good way to modify a class in C++ so that its
How can I modify below class so that the button field is unselectable (never
I'm trying to use the ref keyword in C# to modify a class variable
I'm trying to modify the class of an element if an ajax call based
I have class Fred { public: void inspect() const {}; void modify(){}; }; int
The default description for a class instance returns ClassName: 0x105120. How might I modify
Is there anyway I can modify this code example #include <stdlib.h> #include <iostream> class

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.