1. I had an idea about how the RNG would work in this tutorial based on the previous videos in this series, and I couldn't wait to try it out before watching this video, so I tried writing my own code based on what bucky has gone over so far, and this is what I ended up with. 2. The best part is: it actually works, which is why I'm sharing this! 3. This will also generate a random integer between 0 and 100: (int)(Math.ceil(Math.random()*100)); The only part of that I didn't get from what you've shown so far is the (int) part at the beginning. If you don't include the (int), it will work, but it will give you a decimal number in the tenths place. Also, if you use this code, you don't have to import anything.
thank you, now that 1+ let me lose around 5 hours, I was trying to make a loop if Random elected 0, then repeat the process until it elects non 0. Why would Java does not allow us to create ranges easily? I want to create a Random number from specific range like 201 to 300!! so should I always add values to the variables to achieve this?
I just created a "Diavolo VS Giorno" fight using the Random, the Scanner, if statements and a lot of integers. It turned out so well and to be honest I actually had fun playing it, I guess I was intense when Diavolo was at 1500 HP and Giorno was at 13.
Where does he get "counter" from? I am using eclipse and it tells me that doesn't work here. I haven't had the time to watch his previous videos if he explains earlier that would be nice to know too.
How do you find the Nth smallest number in the randomly generated 500 numbers b/w 100-1000? I have both the codes below.
Is there a way to merge both codes into one code so, to get both results under one console?
//Generate 500 RANDOM numbers
import java.util.Random; public class RandomNumbers {
public static void main(String[] args) { int counter; Random rnum = new Random(); /* Below code would generate 500 random numbers * between 100 and 1000. */ System.out.println("Random Numbers:"); System.out.println("***************"); for (counter = 100; counter <= 500; counter++) { System.out.println(rnum.nextInt(1000)); } } }
When using the Random class, does it equally divide the probability based on how many options you give it? So does dice.nextInt(6) mean each number has a 1/6 probability of occurring?
Who can help with this. There is a drunkard in a grid of streets randomly picks one of four directions and stumbles to the next interaction, and he does the same. If this drunkard walks 100 intersections, where would he be, starting at (0, 0). You are selected to create and design a program to solve the Drunkard's Walk problem.
this was so helpful!! 😀
4:30
Where are you coding?
Best guy I've ever known
Don't you have to initialize the number variable first?
1. I had an idea about how the RNG would work in this tutorial based on the previous videos in this series, and I couldn't wait to try it out before watching this video, so I tried writing my own code based on what bucky has gone over so far, and this is what I ended up with.
2. The best part is: it actually works, which is why I'm sharing this!
3. This will also generate a random integer between 0 and 100:
(int)(Math.ceil(Math.random()*100));
The only part of that I didn't get from what you've shown so far is the (int) part at the beginning. If you don't include the (int), it will work, but it will give you a decimal number in the tenths place. Also, if you use this code, you don't have to import anything.
Thank you for this bro
Sorry I am beginner so why do we need the empty qoutation on the last line
Isn't there any other way to generate a random number between 1 to 43
thank you,
now that 1+ let me lose around 5 hours, I was trying to make a loop if Random elected 0, then repeat the process until it elects non 0.
Why would Java does not allow us to create ranges easily?
I want to create a Random number from specific range like 201 to 300!!
so should I always add values to the variables to achieve this?
bucky you are great man, without ur videos i'll have not pass my exam this year. You condense 3 months of class in like 3 hour. <3
Thank you so much for your tutorials, really easy to understand. I hope your smoker's cough or something is alright. <3
This is ace thanks and your accent is cool!
Where's the Indian accent?
Hi, Can someone tell me how to get code of Math.random() method. i.e., what is the code written inside this method. 🙏🙏🙏🙏
Bucky pronouce dice like : DOICE xD
Good
I just created a "Diavolo VS Giorno" fight using the Random, the Scanner, if statements and a lot of integers. It turned out so well and to be honest I actually had fun playing it, I guess I was intense when Diavolo was at 1500 HP and Giorno was at 13.
// Random dice = new Random();
// int number,number1,number2,number3,number4,number5,number6,number7,number8;
//
// for(int counter = 1; counter < 2; counter++) {
// number = 1 + dice.nextInt(9999);
// number1 = 1 + dice.nextInt(9999);
// number2 = 1 + dice.nextInt(9999);
// number3 = 1 + dice.nextInt(9999);
// number4 = 1 + dice.nextInt(9999);
// number5 = 1 + dice.nextInt(9999);
// number6 = 1 + dice.nextInt(9999);
// number7 = 1 + dice.nextInt(9999);
// number8 = 1 + dice.nextInt(9999);
//
// String firstPrize = String.format("%04d", number).substring(0, 4);
// String secondPrize = String.format("%04d", number1).substring(0, 4);
// String thirdPrize = String.format("%04d", number2).substring(0, 4);
// String fourthPrize = String.format("%04d", number3).substring(0, 4);
// String fifthPrize = String.format("%04d", number4).substring(0, 4);
// String sixthPrize = String.format("%04d", number5).substring(0, 4);
// String seventhPrize = String.format("%04d", number6).substring(0, 4);
// String eighthPrize = String.format("%04d", number7).substring(0, 4);
// String ninthPrize = String.format("%04d", number8).substring(0, 4);
//
// System.out.println("This Week's Draw");
// System.out.println();
// System.out.println("4D 1st Prize: " + firstPrize +" "+" "+" "+" "+" "+" "+" "+" "+" "+"||" + " Prize Money : $2,000,000");
// System.out.println("4D 2nd Prize: " + secondPrize +" "+" "+" "+" "+" "+" "+" "+" "+" "+"||" + " Prize Money : $500,000");
// System.out.println("4D 3rd Prize: " + thirdPrize +" "+" "+" "+" "+" "+" "+" "+" "+" "+"||" + " Prize Money : $250,000");
// System.out.println("4D Starter Prize: " + fourthPrize +" "+" "+" "+" "+" "+"||" + " Prize Money : $20,000");
// System.out.println("4D Starter Prize: " + fifthPrize +" "+" "+" "+" "+" "+"||" + " Prize Money : $20,000");
// System.out.println("4D Starter Prize: " + sixthPrize +" "+" "+" "+" "+" "+"||" + " Prize Money : $20,000");
// System.out.println("4D Consolation Prize: " + seventhPrize +" "+"||" + " Prize Money : $10,000");
// System.out.println("4D Consolation Prize: " + eighthPrize +" "+ "||" + " Prize Money : $10,000");
// System.out.println("4D Consolation Prize: " + ninthPrize +" "+"||" + " Prize Money : $10,000");
// }
Subtitles also needed to understand your pronunciation because different types of people have to watch your videos
what if u wanna generate negative numbers
What if I need to generate a random number from 1000 to 9999?
Where does he get "counter" from? I am using eclipse and it tells me that doesn't work here. I haven't had the time to watch his previous videos if he explains earlier that would be nice to know too.
How do you find the Nth smallest number in the randomly generated 500 numbers b/w 100-1000? I have both the codes below.
Is there a way to merge both codes into one code so, to get both results under one console?
//Generate 500 RANDOM numbers
import java.util.Random;
public class RandomNumbers {
public static void main(String[] args) {
int counter;
Random rnum = new Random();
/* Below code would generate 500 random numbers
* between 100 and 1000.
*/
System.out.println("Random Numbers:");
System.out.println("***************");
for (counter = 100; counter <= 500; counter++) {
System.out.println(rnum.nextInt(1000));
}
}
}
*********************************************************
//Find the Nth smallest number (range from 100 – 1000)
public class Nthsmall {
public static void main(String[] args) {
int numbers [] = {10, 15, 20, -88};
int largest = numbers[0];
int smallest = numbers[0];
for(int i = 1; i<numbers.length; i++) {
if(numbers[i]>largest) {
largest = numbers[i];
}
else if(numbers[i]<smallest) {
smallest = numbers[i];
}
}
System.out.println("List of array is: " + Arrays.toString(numbers));
System.out.println("Largest numbers is : " +largest);
System.out.println("Smallest number is : " +smallest);
}
}
Thank u so much! my lab xm is tomorrow and ur videos saved me
"Since all computer counting starts at 0"
Matlab users lose their shit
who woulda guessed it! its me watching @2019!
i was looking for the EXACT This Lecture for MY TEST!
thanks bro you just help me
I made a Rock Paper Scissors Game:
import java.util.Scanner;
import java.util.Random;
class Main {
public static void main(String[] args) {
Random computer= new Random();
Scanner option = new Scanner(System.in);
System.out.println("================================");
System.out.println("Welcome to Rock, Paper, Scissors");
System.out.println("================================");
System.out.println("Options-");
System.out.println("1-Rock");
System.out.println("2-Paper");
System.out.println("3-Scissors");
System.out.println("================================");
System.out.print("Select an option:");
int play = option.nextInt();
System.out.println("================================");
if ((play==0)||(play>3)){
System.out.println("Error:: Message:"+" Boi You better get that outta here");
}
int ai=1+computer.nextInt(3);
if ((play==1)&&(ai==1)){
System.out.println("Player Chose Rock");
System.out.println("Computer Chose Rock");
System.out.println("A Tie");
}else if ((play==1)&&(ai==2)){
System.out.println("Player Chose Rock");
System.out.println("Computer Chose Paper");
System.out.print("Computer Wins");
}else if ((play==1)&&(ai==3)){
System.out.println("Player Chose Rock");
System.out.println("Computer Chose Scissors");
System.out.print("Player Wins");
}else if ((play==2)&&(ai==1)){
System.out.println("Player Chose Paper");
System.out.println("Computer Chose Rock");
System.out.print("Player Wins");
}else if ((play==2)&&(ai==2)){
System.out.println("Player Chose Paper");
System.out.println("Computer Chose Paper");
System.out.print("A Tie");
}else if ((play==2)&&(ai==3)){
System.out.println("Player Chose Paper");
System.out.println("Computer Chose Scissors");
System.out.print("Computer Wins");
}else if ((play==3)&&(ai==1)){
System.out.println("Player Chose Scissors");
System.out.println("Computer Chose Rock");
System.out.print("Computer Wins");
}else if ((play==3)&&(ai==2)){
System.out.println("Player Chose Scissors");
System.out.println("Computer Chose Paper");
System.out.print("Player Wins");
}else if ((play==3)&&(ai==3)){
System.out.println("Player Chose Scissors");
System.out.println("Computer Chose Scissors");
System.out.print("A Tie");
}
}
}
Food
2019 still watching this Legend !
how to generate a random number from a list?
This guy be recording from the amazon rainforest yet he's still the best java tutorial guy, love your videos bucky!
stop snitching math ranndom
i think this is the 5th time i watch this video, every month i forget how random works….
sooo see ya next month
rather than adding 1, we can just write: dice.nextInt(7); right?
how can i do this with a range of number like 3-6 ?
When using the Random class, does it equally divide the probability based on how many options you give it? So does dice.nextInt(6) mean each number has a 1/6 probability of occurring?
thank you so much, but i did not understand nextInt, can u explain it to me please
Could you tell me. How to make group presentation by Random Number
can i get these random numbers in a sequence,say if i can get these in ascending order
Who can help with this. There is a drunkard in a grid of streets randomly picks one of four directions and stumbles to the next interaction, and he does the same. If this drunkard walks 100 intersections, where would he be, starting at (0, 0). You are selected to create and design a program to solve the Drunkard's Walk problem.
i dont understand how the random numbers generated . Can anyone of you please explain the concept
Why did this guy stop making videos??
And what if I want the numbers to not repeat themselves.. ?.. I need answer.. thx. 🙂
That's my man Bucky lol.
most simply defined in
https://www.youtube.com/watch?v=87dgKf2TzEg