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

Username:   Password: 
 RegisterRegister   
 generating random real numbers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kpayne




PostPosted: Mon Feb 06, 2006 11:39 pm   Post subject: generating random real numbers

need help Sad

with a program to generate 10 random real numbers between:
a. 4 and 5
b. 0 and 10
c. 20 and 30
d. x and y, where x and y are integer values inputted by the user.
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Feb 07, 2006 12:02 am   Post subject: (No subject)

Ok, sounds doable. Now would you be so kind as to post up a little bit of your code so we can see how far you have progressed in solving this problem. Even you don't want to reveal your blindingly top secret algorithms, then pseudocode will do just fine Very Happy.
Code would be preferred though.

Don't forget to use [code] tags when you post it!
kpayne




PostPosted: Tue Feb 07, 2006 12:46 am   Post subject: (No subject)

i just started turing for the first time in my life 3 days ago. Haven't got very far with this program
codemage




PostPosted: Tue Feb 07, 2006 9:07 am   Post subject: (No subject)

Not a problem in the least. Show us what you have so far.
do_pete




PostPosted: Tue Feb 07, 2006 12:48 pm   Post subject: (No subject)

You will need for loops and the Rand.Int (upperNum, lowerNum) statement
sylvester-27




PostPosted: Tue Feb 07, 2006 12:49 pm   Post subject: (No subject)

as long as you don't want us to do your homework for u we can help
Albrecd




PostPosted: Tue Feb 07, 2006 1:24 pm   Post subject: (No subject)

From what I can gather, it seems that you want to generate a random number that includes a decimal, and your problem is that Rand.Int creates a random integer. One possible way of solving this would be to have two Rand.int Statements: one for the number and one for the decimal. Ex:

code:
var number : real
var decimal : int

number := Rand.Int (0, 5)
decimal := Rand.Int (0, 9)
number += decimal / 10
put number
kpayne




PostPosted: Tue Feb 07, 2006 10:05 pm   Post subject: (No subject)

I just needed some pointers and example, which u guys already posted
thankx a lot Very Happy
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: