Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Loop Questions
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sleeperstrike




PostPosted: Sat May 10, 2008 11:25 am   Post subject: 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 Very Happy Very Happy


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 Wink ) would be awesome!!!! Thanks a lot guys.

-Cameron
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat May 10, 2008 12:00 pm   Post subject: RE:Loop Questions

read the Turing Walkthrough
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
sleeperstrike




PostPosted: Sat May 10, 2008 1:36 pm   Post subject: RE:Loop Questions

Still don't really understand it, im kinda failing Turing, thats why i sorta need help Razz
Tony




PostPosted: Sat May 10, 2008 2:14 pm   Post subject: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
S_Grimm




PostPosted: Mon May 12, 2008 11:35 am   Post subject: RE:Loop Questions

the code for 4 is

[edit: code removed]

remember, you have to use randint above that to get the number.

[edit2: also it's Rand.Int, not randint.]
Jessica359




PostPosted: Mon May 12, 2008 11:51 am   Post subject: Re: Loop Questions

Hey,

here is for your guessing game ( just did this in my computer class Laughing )

[edit: attachment removed]
Jessica359




PostPosted: Mon May 12, 2008 11:52 am   Post subject: RE:Loop Questions

Just rearrange it a bit Smile
Carey




PostPosted: Mon May 12, 2008 12:02 pm   Post subject: 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
code:

for [iterator(optional)] : [start index] .. [end index] by [val(optional)]
% code
end for


you can use the iterator inside the for loop. Ex.
code:

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([low#], [high#]). It basically generates (pseudo)random numbers in between [low#] and [high#].

then use if statements like

code:

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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon May 12, 2008 12:39 pm   Post subject: Re: RE:Loop Questions

Carey @ Mon May 12, 2008 12:02 pm wrote:
@A\V and Jessica: Please don't give out answers.

Indeed. Your posts have been edited. Please comply with forum rules.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
sleeperstrike




PostPosted: Tue May 13, 2008 9:43 am   Post subject: 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




PostPosted: Tue May 13, 2008 10:10 am   Post subject: 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




PostPosted: Tue May 13, 2008 10:11 am   Post subject: RE:Loop Questions

I failed the course already im doing a package by myself thats why
Tony




PostPosted: Tue May 13, 2008 11:15 am   Post subject: Re: RE:Loop Questions

sleeperstrike @ Tue May 13, 2008 9:43 am wrote:
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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: