|
-
Jun 7th, 2000, 02:49 AM
#1
Thread Starter
New Member
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?
-
Jun 7th, 2000, 02:52 AM
#2
Thread Starter
New Member
my = much
my = much in topic of post
Ummm now how do I do that?
-
Jun 7th, 2000, 02:55 AM
#3
Hyperactive Member
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]
-
Jun 7th, 2000, 03:47 AM
#4
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
-
Jun 7th, 2000, 12:57 PM
#5
Thread Starter
New Member
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?
-
Jun 7th, 2000, 02:30 PM
#6
Lively Member
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
-
Jun 7th, 2000, 07:55 PM
#7
Hyperactive Member
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
-
Jun 7th, 2000, 08:19 PM
#8
Fanatic Member
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!)
-
Jun 7th, 2000, 10:14 PM
#9
Hyperactive Member
that is breed into all aussies? The thing about never being wrong?
-
Jun 7th, 2000, 10:19 PM
#10
Fanatic Member
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!)
-
Jun 8th, 2000, 11:36 AM
#11
Fanatic Member
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!)
-
Jun 8th, 2000, 12:32 PM
#12
Hyperactive Member
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.
-
Jun 8th, 2000, 12:40 PM
#13
Fanatic Member
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!)
-
Jun 9th, 2000, 03:24 AM
#14
Paul282. This seems like a reasonable answer.
-
Jun 9th, 2000, 03:31 AM
#15
Hyperactive Member
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.
-
Jun 11th, 2000, 07:07 AM
#16
Fanatic Member
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!)
-
Jun 11th, 2000, 04:15 PM
#17
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|