Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Idk what title is appropiate for this lol but someone can help me?

  1. #1
    patzxc is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default Idk what title is appropiate for this lol but someone can help me?

    Java Code:
    switch (TransactionType){           
                    case 'w':
    
                    EndingBalance = InitialBalance - TransactionAmount;
                    NumberOfWithdrawals++;
    
                    System.out.println("Account Number: " + AccountNum);
                    System.out.println("Beggining Balance: $" + InitialBalance);
                    System.out.println("Ending Balance: " + EndingBalance);
                    System.out.println("Total amount withdrawn: $" + TransactionAmount);
                    System.out.println("Number of withdrawals: " + NumberOfWithdrawals);
                    System.out.println("Withdraw again? (1/0): ");
                    again = in.nextInt();
    
                    while (!found)
                    if (again == 0)
                    {     
                        System.out.println("Transaction done!");
                        found = true;
    
                    }
    
                    else if (again == 1)                                       
                    {
                        double finaal;
                        NumberOfWithdrawals++;
    
                        System.out.println("Enter amount to be withdrawn: ");
                        withdrawn = in.nextDouble();
    
                        System.out.println("Account number: " + AccountNum);
    
                        finaal =  EndingBalance - withdrawn;
    
                        System.out.println("Beggining Balance: " + EndingBalance); //What i wanted to happen is to change this into a new variable 
                                                                                 //so it'll be the InitialBalance on the next loop(If the user would like to 
                                                                                 //withdraw again).
    
    
                        System.out.println("Ending Balance: " + finaal);
                        System.out.println("Number of Withdrawals: " + NumberOfWithdrawals);
                        System.out.println("Withdraw again?: (1/0) ");
                        again = in.nextInt();
    
                        found = false;
    
                    }

  2. #2
    kaydell2 is offline Senior Member
    Join Date
    Dec 2012
    Posts
    107
    Rep Power
    0

    Default Re: Idk what title is appropiate for this lol but someone can help me?

    I would make a method called withdraw() and then have a loop in main() that calls withdraw(). What I see in your code is a repeat of the code that withdraws money. You could possibly accomplish what you want to without making a separate method, but it seems like a good idea. That's what methods are for.

  3. #3
    Cyclingjico is offline Member
    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0

    Default Re: Idk what title is appropiate for this lol but someone can help me?

    Stating your perception of what the problem is that you are asking for help with may go a long way towards also finding an appropriate title for the post.....

    Additionally, one might be so inclined to provide code more in-line with an sscce it would be significantly easier for others to determine the actual problem and/or solution.

    One thing I can recommend, isolate out all of the code for the withdrawal menu, and isolate the actual code for conducting the withdrawal, turn these into separate methods, allowing for easier re-use.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Idk what title is appropiate for this lol but someone can help me?

    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Idk what title is appropiate for this lol but someone can help me?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. How to rename GUI Title
    By rjagan in forum New To Java
    Replies: 5
    Last Post: 06-11-2014, 11:51 AM
  2. Help:P i don't even have a title
    By Ophelia in forum New To Java
    Replies: 32
    Last Post: 10-01-2011, 11:40 PM
  3. Replies: 19
    Last Post: 06-10-2011, 07:58 PM
  4. Change the title
    By AndrewSD in forum NetBeans
    Replies: 1
    Last Post: 01-11-2011, 03:23 AM
  5. set * at tab title
    By keffie91 in forum Advanced Java
    Replies: 7
    Last Post: 10-06-2008, 07:21 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
  •