• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

random.math question

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ppl

sorry for my silly question but i'm a newbie
and I think I've confused the .math thing

i want to make a sort program that chose random numbers
to see how things work but it seemed that i confused it a bit

what i though is something like
a for in the beginning like for (i=0; i <10 ; i++
then i though of using the try catch something like
try then i've got troubles about the syntact of random.math and the a catch to hold exceptions and then a system print out with the number it was chosen.


is the way that i'm thinking correct i'm just trying to learn what I'm seeing in the book I bought but sometimes I need to discuss things

sorry for bothering you
Thank you
M.A.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Look carefully at the System.out.println() statement,
if i dont put Math.random() * 10in parentheses, i will get the same values consistently...Think about it...
 
Mary Anderson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see that no try-catch is necessarily needed to do that simple thing (which although caused me troubles )
what I'm seeing for the first time is the 1 in the beggining what I also didn't do is to put the int in ()

thank you very much
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you need more help on this particular program, and when you need help in the future, you should post some code along with the verbal description of what you are trying to do. Code is a much more precise way of illustrating what you are having problems with. Also, when we try to help you, we can talk about the code in a much more precise way, whereas our help may be a bit vague when it comes to trying to decipher the verbal description on it's own. For more information about how to ask effectively questions, you should visit some of the links given in the related section in our FAQ. If you follow the advice given here, more people are likely to take the time to help you. Also, the turn around time will be minimized as many of the suggestions are an effort to help avoid any confusion during communication.

Anyway, I'll get off my soap box now

Keep Coding!

Layne
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic