
-----------------------------------
kpayne
Mon Feb 06, 2006 11:39 pm

generating random real numbers
-----------------------------------
need help :( 

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.

-----------------------------------
Delos
Tue Feb 07, 2006 12:02 am


-----------------------------------
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 :D.
Code would be preferred though.

Don't forget to use [code] tags when you post it!

-----------------------------------
kpayne
Tue Feb 07, 2006 12:46 am


-----------------------------------
i just started turing for the first time in my life 3 days ago. Haven't got very far with this program

-----------------------------------
codemage
Tue Feb 07, 2006 9:07 am


-----------------------------------
Not a problem in the least.  Show us what you have so far.

-----------------------------------
do_pete
Tue Feb 07, 2006 12:48 pm


-----------------------------------
You will need for loops and the Rand.Int (upperNum, lowerNum) statement

-----------------------------------
sylvester-27
Tue Feb 07, 2006 12:49 pm


-----------------------------------
as long as you don't want us to do your homework for u we can help

-----------------------------------
Albrecd
Tue Feb 07, 2006 1:24 pm


-----------------------------------
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:

var number : real
var decimal : int

number := Rand.Int (0, 5)
decimal := Rand.Int (0, 9)
number += decimal / 10
put number

-----------------------------------
kpayne
Tue Feb 07, 2006 10:05 pm


-----------------------------------
I just needed some pointers and example, which u guys already posted 
thankx a lot :D
