I'm trying to work on a basic checking account program. It will eventually allow the user to make a deposit or withdrawal to an account. I honestly have no idea what I'm doing wrong here, but I'm hoping it's just something incredibly stupid.

//Deposit and Withdraw Funds

package deposit_withdraw;

import java.util.Scanner;



public class Main {



    public static void main(String[] args) {
          Scanner input = new Scanner( System.in);

          float changeAmount, oldBalance, newBalance;
          int num1;
          
          Account myAccount = new Account("abc", 0, 0, 0);

          newBalance = 0;

    System.out.print("Please enter 1 to deposit, or 2 to withdraw."); //Get user's choice
    num1 = input.nextInt();

//Still need to add in the actual choice process
  
        System.out.print("Enter the ammount to be deposited to the account:");//Get changeAmount
           changeAmount = input.nextFloat();

           oldBalance = myAccount.getBalance;
           newBalance = oldBalance + changeAmount;
           myAccount.setBalance(newBalance);
           oldBalance = myAccount.getBalance;
                   System.out.printf("The new balance is: %d\n", oldBalance);
   }

  
  
    }

}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author David
 */
public class Account {
    //Private fields
    private float Balance, inAmount, outAmount;
    private String accountName;

    //Constructor
    public Account(String Name, float Balance, float inAmount, float outAmount)
    {
        this.accountName = Name;
        this.Balance = 0;
        this.inAmount = 0;
        this.outAmount = 0;
    }

    //Accessors
    public float getBalance()
    {
        return Balance;
    }

    public float getInAmount()
    {
        return inAmount;
    }

    public float getOutAmount()
    {
        return outAmount;
    }

    //Mutators
    public void setAccountName(String Name)
    {
        accountName = Name;
    }
    public void setBalance(float Balance)
    {
        this.Balance = Balance;
    }

}

And the error I'm getting when I try to compile is:

C:\Users\David\Documents\NetBeansProjects\deposit_withdraw\src\deposit_withdraw\Main.java:19: cannot find symbol
symbol : class Account
location: class deposit_withdraw.Main
Account myAccount = new Account();
C:\Users\David\Documents\NetBeansProjects\deposit_withdraw\src\deposit_withdraw\Main.java:19: cannot find symbol
symbol : class Account
location: class deposit_withdraw.Main
Account myAccount = new Account();


I would greatly, greatly appreciate any help. I'm about to tear my hair out, I just have no clue what I'm doing wrong.

Thanks,

Terz

If both files under the same folder,
(1)remove line 3 in the file Main.java, i.e. remove "package deposit_withdraw;"
(2) in lines 31 and 34 in Main.java,
the method getBalance should be written as
myAccount.getBalance();

If both files under the same folder,
(1)remove line 3 in the file Main.java, i.e. remove "package deposit_withdraw;"
(2) in lines 31 and 34 in Main.java,
the method getBalance should be written as
myAccount.getBalance();

Thanks so much, that got it to compile, very appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.