This is what I got I have tried understanding what I am doing wrong I am really lost and I am begging anyone to help me PLEASE?!?
// Fig. 3.12: AccountTest.java
// Create and manipulate an Account object.
public class Account
{
private double balance; // instance variable that stores the balance
// constructor
public Account( double initialBalance )
{
// validate that initialBalance is greater than 0.0;
// if it is not, balance is initialized to the default value 0.0
if ( initialBalance > 0.0 )
balance = initialBalance;
} // end Account constructor
// debit (subtract) an amount to the account
public void debit( double amount )
{
balance = balance - amount; // add amount to balance
// end method debit
}
if(debitAmount>account1.getBalance())
{
System.out.printf("You don't have enough money for this transaction, the amount available is $%.2f",getBalance());
}
else
{
account1.debit(debitAmount);
System.out.printf("The new balance is $%.2f",getBalance());
}
//And for AccountTest.java:
public class AccountTest {
// main method begins execution of Java application
public static void main( String args[] )
{
Account account1 = new Account( 50.00 ); // create Account object
double currentBalance = account1.getBalance();
// display initial balance of each object
System.out.printf( "account1 balance: $%.2f\n",
currentBalance );
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
double debitAmount; // debit amount read from user
System.out.print( "Enter withdrawl amount from your account: " ); // prompt
debitAmount = input.nextDouble(); // obtain user input
if(debitAmount > currentBalance)
{
System.out.printf("Debit amount of $%.2f is greater than the Available Balance of $%.2f.%n",debitAmount,currentBalance);
}
else
{
System.out.printf( "\nwithdrawling %.2f to account1 balance\n\n", debitAmount );
account1.debit( debitAmount ); // add to account1 balance
currentBalance = account1.getBalance();
}
// display balances
System.out.printf( "account1 balance: $%.2f\n", currentBalance );
} // end main
}