Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

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

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    My question's inside the "//"


    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
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,602
    Thanks
    45
    Thanked 1,956 Times in 1,930 Posts

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

    change this into a new variable so it'll be the InitialBalance on the next loop(I
    Define a variable to hold the value and then assign it to the desired variable on the next loop.

    Does the posted code show the loop you are talking about?

    You should use {}s with ALL while and if statments to enclose the code that goes with them.
    It's hard to see the end of the while statement in the posted code because the code is not enclosed in {}s

    Also statements inside of loops should be indented 3-4 spaces so you can easily see the logic.

    Also posted at http://www.java-forums.org/new-java/...n-help-me.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Help lol
    By r_james14 in forum Java Theory & Questions
    Replies: 1
    Last Post: April 14th, 2012, 02:15 PM
  2. Idk what is wrong
    By Devourz in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 28th, 2011, 05:05 AM
  3. Frustrated lol.
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 14th, 2010, 09:02 PM
  4. Replies: 5
    Last Post: August 5th, 2010, 09:16 PM
  5. LOL ROLF TTYL
    By JavaGreg in forum Member Introductions
    Replies: 3
    Last Post: August 5th, 2009, 02:13 PM