Results 1 to 3 of 3
  1. #1
    SOLOshadow is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default 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.
    Java 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);
    }
    }
    So here is the excerpt from the code that I believe my professor was talking about
    Java Code:
    nicksAcct.setCheckMoney(0);
    nicksAcct.setSaveMoney(0);
    carolAcct.setSaveMoney(1700);
    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."

    thanks for any and all help

  2. #2
    jlmp is offline Member
    Join Date
    Sep 2010
    Posts
    21
    Rep Power
    0

    Default

    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

  3. #3
    SOLOshadow is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default

    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

  1. Constructor with unknown amount of objects?
    By Bernard Robitaille in forum New To Java
    Replies: 5
    Last Post: 03-01-2009, 05:00 AM
  2. Work & Earn money from home, use rebate lower price save money $$$
    By arturmoniswork in forum Reviews / Advertising
    Replies: 0
    Last Post: 12-30-2008, 05:57 AM
  3. Java Intermediate
    By MarKus in forum New To Java
    Replies: 2
    Last Post: 09-10-2008, 01:58 PM
  4. Intermediate Java section?
    By fishtoprecords in forum Suggestions & Feedback
    Replies: 6
    Last Post: 07-17-2008, 12:55 AM
  5. convert a java binary/executable to a intermediate language
    By sumit_400461 in forum Advanced Java
    Replies: 1
    Last Post: 07-13-2008, 07:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •