[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 334 KB, 600x776, chewbacca-on-a-giant-squirrel-fighting-nazis-youcallthatamovie.jpg [View same] [iqdb] [saucenao] [google]
4236867 No.4236867 [Reply] [Original]

hey /sci/
so I'm trying to teach myself Java and I think I've started off okay but I seem to have come to a dilemma.
I want a code that will choose a random double random_wanted and if that double is not .99999999, I want it to repeat until it attains .99999999.
So far here's my code, I just don't have enough knowledge about this to actually know what to do.

import java.io.*;
import java.util.Random;
public class Tester
{
public static int main(String args[])
{
double random_wanted=Math.random();

if(random_wanted<.999999999999999)
{


tl;dr a person who's new at java is looking for some coding help

>> No.4236891
File: 40 KB, 400x400, sheldon.jpg [View same] [iqdb] [saucenao] [google]
4236891

>2012
>using a shit tier language

>> No.4236915

all these thread :
>>>/g/

>> No.4236918

> looking for a specific double value
Please don't do this.

>> No.4236927

Okay, lots of gripe here...

How about this, why are you looking for the number 0.9999_whatever? That would help the thread understand your intent.

(Also, you might be there a looooooong time.)

>> No.4236939

>>4236927
I'm looking fto see how many times the random method has to be used until such number appears. Kind of like me seeing how many times I have to roll a die for me to get a 1.

>> No.4236947

You just need a while loop or for loop there, and a lot of time. Might want to start with fewer 9s to test it.