a. is the amount and the balance the same? yes or no, why? class CheckingAct { . . . . private int balance; public void processCheck( int amount ) { int amount; incrementUse(); if ( balance < 100000 ) amount = 15; // which amount ??? else amount = 0; // which amount ??? balance = balance - amount ; // which amount ??? } } b. is the balance the same? yes, no? why? class CheckingAct { . . . . private int balance; . . . . public void processDeposit( int amount ) { int balance = 0; // New declaration of balance. balance = balance + amount ; // This uses the local variable, balance. } }
a. is the amount and the balance the same? yes or no, why?
class CheckingAct
{
. . . .
private int balance;
public void processCheck( int amount )
{
int amount;
incrementUse();
if ( balance < 100000 )
amount = 15; // which amount ???
else
amount = 0; // which amount ???
balance = balance - amount ; // which amount ???
}
}
b. is the balance the same? yes, no? why?
class CheckingAct
{
. . . .
private int balance;
. . . .
public void processDeposit( int amount )
{
int balance = 0; // New declaration of balance.
balance = balance + amount ; // This uses the local variable, balance.
}
}
Step by step
Solved in 2 steps