Home > Hammers > 20 999 Series

20 999 Series

October 9th, 2009

20 999 Series
Check out this page if you are looking for 20 999 Series

No items matching your keywords were found.

20 999 Series
Programming Libery BASIC?

I'm using Liberty Basic. This is homework, I don't want someone to code the answer for me. I just need some guidence. The Problem:

Allow the user to enter a series of temperatures in degrees Celsius terminated by the input of -999. Fore each one, find the corresponding temperature in degrees Fahrenheit.

My question is, what do I use to store the several values of tempatures inputed? I could possibly use an array like:

dim Tempature(20)
print "Please enter Tempatures."
for index = 1 to 20
input Tempature : Tempature(index) = Tempature
next index

I'm not sure that's 100% right, but even if that is the approach I need, how to I call out each individual Temature and have it stored in a variable for converstion to Degrees Fernheit ?

Any help would be greatly appreciated. Thank you.

You're on exactly the right track. Use an array like you've defined, and use it again for any manipulations you do on the individual temperatures in it.

But I'm not sure about that

input Tempature : Tempature(index) = Tempature

line. I don't remember if Basic permits the use of a colon to separate statements on a single line, but as a professional programmer, I've found it's generally a good idea to give every statement its own line. Makes it much easier to delete or move lines without inadvertently disturbing the program logic.

And I'm pretty sure you won't be able to have both a single variable Tempature for the input and an array with the same name. If Basic doesn't give you a message about this, it may lead to a confusing bug.

Hope that helps.

Thanks for looking at our 20 999 Series information.


Click on Hammers for even MORE awesome stuff.

Categories: Hammers Tags: , , , ,
Comments are closed.