chan 06's Profile User Rating: -----

Reputation: 3 Apprentice
Group:
Members
Active Posts:
41 (0.18 per day)
Joined:
07-October 12
Profile Views:
1,288
Last Active:
User is offline May 20 2013 06:14 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   chan 06 has not set their status

Posts I've Made

  1. In Topic: Unsure about OOP

    Posted 15 May 2013

    Was a nice idea on implementing to my programming, thanks a lot.
    public static void main(String args[]){
    }
    


    I will look further on the link you sent me, thanks a lot.
  2. In Topic: Storing Random Numbers

    Posted 6 May 2013

    Ah found error, it was the random number that was having problems. Fix it! Thanks for your help guys.
  3. In Topic: Storing Random Numbers

    Posted 6 May 2013

    View Postdarek9576, on 06 May 2013 - 04:48 AM, said:

    You might be missing break statements in the switch() statement. Have you tried debugging it?


    How to debug, I am fairly unfamiliar with Java debugging tool. I am currently using Eclipse IDE. Yes, I added all break in the switch(), and made no difference at all.

    Edited.
  4. In Topic: writing a simple atm program

    Posted 22 Apr 2013

    View Postmwtack567, on 19 April 2013 - 05:31 PM, said:

    I am trying to write a simple program as an atm that lets the user withdraw or deposit. The problem I have is getting the deposit amount to work. here is the code i am using, please tell me what i am doing wrong.
            dpst = input("HOW MUCH WOULD YOU LIKE TO DEPOSIT? ")
    
            dpst_bal = str(new_bal + dpst)
    
            print ("BEGINNING BALANCE: $" + str(balance))
            print ("NEW BALANCE: $" + str(dpst_bal))
    


    It will print the beginning balance, but where I want the new balance with the deposit I get new_bal + dpst


    So basically what you are doing wrong is that your dpst_balance it is set to string variable. Although we want to make sure that we are dealing with float (double) numbers. So a quick fix is to make sure that you organize your code a bit cleaner and make sure to convert into float.

    # Declare your new balance and deposit variable, and set to your intial value.
    # Since Python won't know what variable you are talking about.
    new_bal = 0.0
    dpst_bal = 0.0
    
    # Creates a dpst variable that converts float.
    # Note: you cannot enter string, it will give you a ValueError.
    dpst = float(input("HOW MUCH WOULD YOU LIKE TO DEPOSIT?"))
    
    # Make sure to declare a variable for new_bal, or also it will give error
    new_bal = dpst_bal + dpst
    
    # Make sure you re-use your variable.
    # Note: I saw your program that you created new variable
    print("BEGINNING BALANCE: $", dpst_bal)
    print("NEW BALANCE: $", new_bal)
    


    Few things to keep in note is:
    - Don't create unnecessary variables, as I see you create a lot of variables.
    variable

    - Concatenate your variables only if is between a sentence, it is more efficiency and neater.
    new_value = 10
    print("This is when you should concatenate " +str(new_value) + "-value.")
    


    Pretty much your code doesn't seem bad for first programmer, just keep in track of your variables :), hope that helped.
  5. In Topic: Error through looping

    Posted 17 Apr 2013

    Alright, I see what you means. Yes that's right, I was confused one my loop wouldn't iterate through all the lists before checking one of the arguments above, once again thanks for help.

    View PostMekire, on 17 April 2013 - 03:46 PM, said:

    We loop through the entire list. If at any point we find the item we are looking for, the function returns the index. If we loop through the entire list without finding it, we return negative one. enumerate is the pythonic way to loop through an iterable if you are going to also need the index; every time it loops, i is incremented by one, and guy is assigned the next item in the list.

    Only after the for loop has looked (and rejected) every item, do we proceed to return negative one. Your function on the other hand, looked at the first item; checked if it was correct; and if it wasn't it immediately returned negative one. It never proceeded to the second item because under both conditions you stopped the loop. If a function at any point hits a return statement, then that function ends. I believe that is (one of) the points of confusion here.

    -Mek

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

chan 06 hasn't added any friends yet.

Comments

chan 06 has no profile comments yet. Why not say hello?