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
Printable View
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
my = much in topic of post
i am not sure exactly what you mean, but why use variables
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:Print txtFtemp.Text
Print (5/9)*(val(txtFtemp.Text)-32)
Of course this is limited to integers which I guess is ok for general conversions.Code:Public Function FarenToCel(ByVal FarenTemp As Integer) As Integer
FarenToCel = (5/9)*(val(FarenTemp)-32)
End Function
[Edited by billrogers on 06-07-2000 at 04:01 PM]
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
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}?
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
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
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 :D
that is breed into all aussies? The thing about never being wrong?
YEP !!
We're all very clever!!
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!
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:
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.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
So if I were to write the Algorithm such that it could be processed in Assembly Language it would look like this :
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.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
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.
Personally I think that VB makes good pseudo code.
Paul282. This seems like a reasonable answer.Quote:
C = (5/9)X(F-32)
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.
That's funny, My previous post contained the meaning from a dictionary ;)Quote:
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".
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]