Results 1 to 17 of 17

Thread: My teacher says my algorithim is too my VB code!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    10

    Question My teacher says my algorithim is too much VB code

    WE had to make algorithim for this forumla. C=5/9x(F-32}

    i did.

    1. Ftemp = txtFtemp.txt
    1.1Ctemp = txtCtemp.txt
    2.Ctemp= (5/9) (Ftemp-32)
    3.Print Ctemp and Ftemp
    Ummm now how do I do that?

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    10

    my = much

    my = much in topic of post
    Ummm now how do I do that?

  3. #3
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    i am not sure exactly what you mean, but why use variables

    Code:
    Print txtFtemp.Text
    Print (5/9)*(val(txtFtemp.Text)-32)
    To compute that function you do not need an alogrithm per se, now on the other hand if you are talking about good coding, maybe you should write a function to do conversion.

    Code:
    Public Function FarenToCel(ByVal FarenTemp As Integer) As Integer
    
    FarenToCel = (5/9)*(val(FarenTemp)-32)
    
    End Function
    Of course this is limited to integers which I guess is ok for general conversions.

    [Edited by billrogers on 06-07-2000 at 04:01 PM]

  4. #4
    Guest
    Or just use this. Make a Form with 2 TextBoxes and a CommandButton.

    Code:
    Private Sub Command1_Click()
    
        RetVal = (5 / 9) * (Text1 - 32)
        Text2 = Int(RetVal)
    
    End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    10
    Its supose to be just a algorithim.No VB code.

    Does my algorithim have too much VB code and is it correct to do such a formala.[converting F to C}?
    Ummm now how do I do that?

  6. #6
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99

    Talking

    Is the algorithm supposed to be language independent. If so I imagine your tutor is after pseudocode.

    1. Input Farenheit temperature
    2. Convert to Celcius
    3. Output results


  7. #7
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    Alogrithms are language independant, they are usually written in pseudo code,

    1. Read in faren. temp
    2. Print faren. temp
    3. Cel. temp <- (5/9)(faren. temp - 32)
    4. Print Cel. temp

  8. #8
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    Maybe your teacher doesn't want to know anything about programming languages and just wants the algorithm ! (Because it's like, a maths class not a programming class ??)

    Just get rid of all the text1 and ".text" stuff



    C = (5/9)X(F-32)



    TaDaaaa !

    If this isn't what you're teacher means then he/she is a moron because I'm never wrong



    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  9. #9
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    that is breed into all aussies? The thing about never being wrong?

  10. #10
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Talking

    YEP !!

    We're all very clever!!
    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  11. #11
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Unhappy

    This question has been annoying me.

    Algorithm
    n : a precise rule (or set of rules) specifying how to solve some problem.

    What's the difference between that and the origonal formula?

    How about:
    X = 5 / 9
    Y = F - 32
    C = X x Y

    It's still the same bloody thing!


    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  12. #12
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    I think you are all missing the point of an "algorithm".

    It isn't just a set of rules but also the "method" by which you do it... So you could in a sense consider it "pseudo-code".

    Algorithm:
    Code:
    1. Assign a value to F
    2. Subtract 32 from the result
    3. Multiple the result by ( 5 / 9 )
    4. Assign the result to C
    5. Display the result contained in C
    This is the "Algorithm" that is used in order to get the formula. Even though you can simply write C=(5/9)*(F-32) internally the computer has to do it differently because it cannot do it all at once.

    So if I were to write the Algorithm such that it could be processed in Assembly Language it would look like this :

    Code:
    1. Input Value
    2. Assign Value to Memory Address referenced by F
    3. Copy F to REGISTER1
    4. Subtract 32 from REGISTER1
    5. Assign 5 to REGISTER2
    6. Divide contents of REGISTER2 by 9
    7. Multiple contents of REGISTER1 by REGISTER2
    8. Copy REGISTER1 to Memory Address referenced by C
    9. Output contents of Variable C
    This is the only way a computer could do this equation because it needs to break it down into compeltely individual steps storing each part in a REGISTER.

    Of course this isn't obvious unless you were explaining a formula that wasn't as simple as conversions of temperature.

    If you were asked to show the algorithm for BUBBLESORT for instance then it would all make more sense.

  13. #13
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    Personally I think that VB makes good pseudo code.

    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  14. #14
    Guest
    C = (5/9)X(F-32)
    Paul282. This seems like a reasonable answer.

  15. #15
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    I think he is young, for this is really to easy to warrant an algorithm, granted as per definition it is in fact an algorithm.

    A one line algorithm should work.

  16. #16
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Talking

    Originally posted by Gen-X
    I think you are all missing the point of an "algorithm".

    It isn't just a set of rules but also the "method" by which you do it... So you could in a sense consider it "pseudo-code".
    That's funny, My previous post contained the meaning from a dictionary




    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  17. #17
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Talking The lighter side of...

    ALGORITHM pronounced: Algae Rhythm.
    Describing the movement of a person, moments before he hits the ground after being whacked on the head with a 2-by-4.

    Derived from the movement made by Algea in a slow moving stream.

    [Edited by r0ach on 06-12-2000 at 11:17 AM]

    r0ach™
    Don't forget to rate the post

Posting Permissions

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



Click Here to Expand Forum to Full Width