Results 1 to 3 of 3
- 09-25-2010, 12:01 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 2
- Rep Power
- 0
use an intermediate variable in the money transfer and not manually input the amount
Hey so this is my code for a certain Bank Driver Class. I submitted it to my professor and he said it works but he wants me to "use an intermediate variable in the money transfer and not manually input the amount" can anyone help me out on how to do this. The assignment is already completed and I have already received the grade on it so I am just wondering, for my personal knowledge how to do it for future assignments.
So here is the excerpt from the code that I believe my professor was talking aboutJava Code:public class BankingDriver.java{ public static void main (String[] args){ Banking nicksAcct = new Banking("Nick", 400, 500); Banking carolsAcct = new Banking("Carol", 600, 700); System.out.println(nicksAcct.getTotalMoney()); System.out.println(carolsAcct.getTotalMoney()); nicksAcct.setCheckMoney(400); nicksAcct.setSaveMoney(500); carolsAcct.setCheckMoney(600); carolsAcct.setSaveMoney(700); nicksAcct.setCheckMoney(0); nicksAcct.setSaveMoney(0); carolAcct.setSaveMoney(1700); System.out.println(NicksAcct); System.out.println(CarolsAcct); } }
and the prompt for it was " move all of the money in Nick's account - both checking and savings - to Carol's savings account. This should leave Nick penniless at the end. Here, first move the money in Nick's savings account, and then his checking account, to an intermediate variable, setting Nick's money to 0; then add the money in that intermediate variable to Carol's account."Java Code:nicksAcct.setCheckMoney(0); nicksAcct.setSaveMoney(0); carolAcct.setSaveMoney(1700);
thanks for any and all help
- 09-25-2010, 12:30 AM #2
Member
- Join Date
- Sep 2010
- Posts
- 21
- Rep Power
- 0
I am not sure what your code has to do, but i noticed this:
You have two instances whose parameters are a String for their name and two integers for their money. And then you send messages for them (setCheckMoney(int money), saveCheckMoney(int money)) whose parameteres have the same value as before. I am not following your code but if these methods have to have the same values for their parameters this means that you could use an intermediate variable. It could be in your constructor of the class Banking...
Still i am not sure what your code does, so maybe my answer would not help you at all :S
- 09-25-2010, 07:03 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 2
- Rep Power
- 0
Well this is what the Program is supposed to do, this is the prompt:
Create an object called nicksAcct. Nick has $400 in his checking account, and $500 in his savings account.
Create an object called carolsAcct. Carol has $600 in her checking account, and $700 in her savings account.
Print out the total amount of money in both accounts (you must use methods from the Banking class here to obtain the the various amounts that contribute to the final total). This total should be the sum of the money in both of Nick's accounts added to the sum of the money in both of Carol's accounts.
Add $100 to Nick's checking account.
Print out statistics on Nick's account. This statement: System.out.println(nicksAcct); will do the trick.
In a series of statements, move all of the money in Nick's account - both checking and savings - to Carol's savings account. This should leave Nick penniless at the end. Here, first move the money in Nick's savings account, and then his checking account, to an intermediate variable, setting Nick's money to 0; then add the money in that intermediate variable to Carol's account.
Print out statistics on Nick's account
Print out statistics on Carol's account
The part I had trouble with is
"Well this is what the Program is supposed to do, this is the prompt:
Create an object called nicksAcct. Nick has $400 in his checking account, and $500 in his savings account.
Create an object called carolsAcct. Carol has $600 in her checking account, and $700 in her savings account.
Print out the total amount of money in both accounts (you must use methods from the Banking class here to obtain the the various amounts that contribute to the final total). This total should be the sum of the money in both of Nick's accounts added to the sum of the money in both of Carol's accounts.
Add $100 to Nick's checking account.
Print out statistics on Nick's account. This statement: System.out.println(nicksAcct); will do the trick.
In a series of statements, move all of the money in Nick's account - both checking and savings - to Carol's savings account. This should leave Nick penniless at the end. Here, first move the money in Nick's savings account, and then his checking account, to an intermediate variable, setting Nick's money to 0; then add the money in that intermediate variable to Carol's account."
Similar Threads
-
Constructor with unknown amount of objects?
By Bernard Robitaille in forum New To JavaReplies: 5Last Post: 03-01-2009, 05:00 AM -
Work & Earn money from home, use rebate lower price save money $$$
By arturmoniswork in forum Reviews / AdvertisingReplies: 0Last Post: 12-30-2008, 05:57 AM -
Java Intermediate
By MarKus in forum New To JavaReplies: 2Last Post: 09-10-2008, 01:58 PM -
Intermediate Java section?
By fishtoprecords in forum Suggestions & FeedbackReplies: 6Last Post: 07-17-2008, 12:55 AM -
convert a java binary/executable to a intermediate language
By sumit_400461 in forum Advanced JavaReplies: 1Last Post: 07-13-2008, 07:04 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks