
-----------------------------------
sleeperstrike
Sat May 10, 2008 11:25 am

Loop Questions
-----------------------------------
I currently need help with these two questions, i really don't get how to do them. I will appreciate it if someone helps me :D :D


1. Write a program which will display a conversion table from miles to kilometers (1 mile = 1.6km). design the program so that the value for miles increase by 5. The table will start with 5 and end with 100 miles. 

1a. Modify the program in #1 so that it will allow the user to specifiy the starting and ending values of the table. The user will also be able to specify the increments. a sample run of the new program might look like this,



Conditional Loops

2.   Write a program which generates a random number between 1 and 10. prompt the user to guess the number. Continue prompting the user for a guess until the proper number is guessed.

2a. Modify #2 to program in question #1 by generating a number between 0 and 100. After each guess, tell the user whether the guess was Too High! or Too Low!



Any help with these questions ( or all 4 ;) ) would be awesome!!!! Thanks a lot guys.

-Cameron

-----------------------------------
Tony
Sat May 10, 2008 12:00 pm

RE:Loop Questions
-----------------------------------
read the Turing Walkthrough

-----------------------------------
sleeperstrike
Sat May 10, 2008 1:36 pm

RE:Loop Questions
-----------------------------------
Still don't really understand it, im kinda failing Turing, thats why i sorta need help :P

-----------------------------------
Tony
Sat May 10, 2008 2:14 pm

RE:Loop Questions
-----------------------------------
if you are behind on the basics of Turing, then it's absolutely in your best interest to catch up on the Turing Walkthrough

first question is about for loop

second is about a loop with a if-elsif-else statement

-----------------------------------
S_Grimm
Mon May 12, 2008 11:35 am

RE:Loop Questions
-----------------------------------
the code for 4 is

Rand.Int, not randint.]

-----------------------------------
Jessica359
Mon May 12, 2008 11:51 am

Re: Loop Questions
-----------------------------------
Hey,

here is for your guessing game ( just did this in my computer class :lol: )

[edit: attachment removed]

-----------------------------------
Jessica359
Mon May 12, 2008 11:52 am

RE:Loop Questions
-----------------------------------
Just rearrange it a bit  :)

-----------------------------------
Carey
Mon May 12, 2008 12:02 pm

RE:Loop Questions
-----------------------------------
@A\V and Jessica: Please don't give out answers. Only suggestions, hints, or a partial code that cannot be just directly copied and pasted.

@sleeperstrike: syntax for a for loop is

for [iterator(optional)] : [start index] .. [end index] by [val(optional)]
% code
end for


you can use the iterator inside the for loop. Ex.

for i : 0 .. 100 by 2
put i
end for


Would print 0, 2, 4, 6, 8, 10, 12 ..... 96, 98, 100

That should help with your first question.

With regard to your second question:

look upRand.Int(. It basically generates (pseudo)random numbers in between 
if [statement is true] then
%do stuff
end if

you can use that > or < or = operators for the statement to pick if the number is too big, small or is equal.

Hope that helped

-----------------------------------
Tony
Mon May 12, 2008 12:39 pm

Re: RE:Loop Questions
-----------------------------------
@A\V and Jessica: Please don't give out answers.
Indeed. Your posts have been edited. Please comply with forum rules.

-----------------------------------
sleeperstrike
Tue May 13, 2008 9:43 am

RE:Loop Questions
-----------------------------------
Hey guys, seriously, not to be rude, but i dont get Turing. I am failing the course and i need whatever help i can get. I have to hand this thing in by Wednesday, i really need help, i dont understand these questions! Ive tried writing some stuff up but it never works. I just dont understand it.. 

Thanks to A\V and Jessica, but i guess im to late and Tony erased your helpful messages that could save me my life right now.

Please help me out guys, please.

-----------------------------------
jernst
Tue May 13, 2008 10:10 am

Re: Loop Questions
-----------------------------------
Have you tried going to you teacher and explaining that you don't understand any of it and asking for help?

-----------------------------------
sleeperstrike
Tue May 13, 2008 10:11 am

RE:Loop Questions
-----------------------------------
I failed the course already im doing a package by myself thats why

-----------------------------------
Tony
Tue May 13, 2008 11:15 am

Re: RE:Loop Questions
-----------------------------------
Tony erased your helpful messages
They weren't at all helpful.

It sounds like you would have simply handed in their code (likely without giving them any credit). Now if their style of coding is different enough, you get caught for plagiarism right away. Otherwise you simply skip over understanding the basics and will not be able to do any subsequent assignment either.

There are plenty of hints in this thread to get you started, and you still have a whole day to finish the assignment. If you don't understand something, ask very specific questions.
