Monday, July 27, 2009

More Java help please.?

Account


-balance: double


+getBalance(): double


+charge(sale: double): void


+makePayment(payment: double) : void


+printStatement(): void


+Account()





a. Use the class above to write a few lines of code that will create a new


account, with a zero balance (this is what the default constructor will do).


b. Charge three sales to your account created in a) for $25.13, $43.98, and


$5.00.


c. Make a $50 payment to your account in a).


d. Print out a statement for your account in a) if the account has a balance of


over $1.

More Java help please.?
do it yourself. And shame on people who just post code for people who want someone else to do their homework. Show some honor.
Reply:OK, I'll do it for you because I don't have anything better to do, but I want you to read and understand the code:





class Account


{


double balance;


double getBalance()


{


return balance;


}


void charge (double sale)


{


balance=balance+sale;


}


void makePayment(double payment)


{


balance=balance-payment;


}


void printStatement()


{


System.out.println("STATEMENT:


\n*balance="+


balance+"\n---------------");


}


Account()


{


balance=0;


}


}





public class BalanceAccount


{


public static void main(String [] args)


{


Account Acc=new Account();


Acc.charge(25.13);


Acc.charge(43.98);


Acc.charge( 5.00);


Acc.makePayment(50);


if(Acc.getBalance()%26gt;1)


Acc.printStatement();


else


System.out.println("


balance%26lt;=1");


}


}
Reply:first one's free... all orders for homework help are $39.99 per answer...





Try reading through the book some, might help understand basics of Java like: void, constructor or even double. Then doing it yourself would be quick n easy.


No comments:

Post a Comment