Question

Create applications that use Math. random() to generate random numbers for each of the following situations: 3. a) Random51 1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

Code:

class ya{
   public static void main(String args[]){
       int a=99,b=52;
       int number=(int) (Math.random()*((b-a)+1))+a;
       System.out.println("Random integer between 51 and 100 is "+number);
   }
}

Output:

Random integer between 51 and 100 is 54

b)

Code:

class second{
   public static void main(String args[]){
       int a=121,b=199;
       int number=(int) (Math.random()*((b-a)+1))+a;
       System.out.println("Random integer between 121 and 200 is "+number);
   }
}

Output:

Random integer between 121 and 200 is 126

c)

Code:

class third{
   public static void main(String args[]){
       int a=40,b=50;
       int number=(int) (Math.random()*((b-a)+1))+a;
       System.out.println("Random integer between 40 and 50,inclusive is "+number);
   }
}

Output:

Random integer between 40 and 50, inclusive is 44,

Add a comment
Know the answer?
Add Answer to:
Create applications that use Math. random() to generate random numbers for each of the following situations:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For this assignment, write a program that will generate random numbers in the range of 50-100...

    For this assignment, write a program that will generate random numbers in the range of 50-100 and count how many fall into particular ranges. Processing: The program should first seed the random number generator. This is done one time in the program. Use srand(0). Next, generate and display a series of 10 random numbers between 50 and 100. There are several ways to ensure that a random number falls between 50 and 100. One possibility is to use the following...

  • 2. You use random.randint to generate random numbers between 2 and 12 (inclusive), and get (a)...

    2. You use random.randint to generate random numbers between 2 and 12 (inclusive), and get (a) 2 and then (b) 7. What is the information content of each of these two outcomes?

  • Javascript Write a program to generate random numbers between a user-specified range, then count and display...

    Javascript Write a program to generate random numbers between a user-specified range, then count and display the frequencies of the most / least appeared numbers. Sample Output How many random numbers? 1000000 Enter the minimum number: 100 Enter the maximum number: 200 Generated 1000000 random numbers between 100 (inclusive) and 200 (exclusive). Number 133 has the most occurrences (10197). Number 154 has the least occurrences (9749).

  • Programming C++ Language, PLEASE HELP, Will upvote Write a program that first generates two random decimal...

    Programming C++ Language, PLEASE HELP, Will upvote Write a program that first generates two random decimal numbers within the range -100 to 100 inclusive. Next, generate a random number between 1 and 4 inclusive to correspond to each of our math operators (+, -, *, /). Finally, write out to a file called mathWorksheet.txt the following format: A o B = ? With A and B replaced by the two random numbers that were generated and o replaced by the...

  • Integer Math Create an application that uses random integers to test the user’s knowledge of arithmetic....

    Integer Math Create an application that uses random integers to test the user’s knowledge of arithmetic. Let the user choose from addition, subtraction, multiplication, and division. The integers used in the problems should range from 20 to 120. When giving feedback, use color to differentiate between a correct answer response, versus an incorrect answer response. Also check for non-integer input. Preparing division problems requires special consideration because the quotient must be an integer. Therefore, you can use a loop to...

  • cout<<"blah<<endl; no std:cout C++ pointers Generate 25 integer random numbers between 0-100 and place them in...

    cout<<"blah<<endl; no std:cout C++ pointers Generate 25 integer random numbers between 0-100 and place them in a file, each number on a single line.. Dont forget to close the file once the numbers are generated. Then read the file and create a dynamic array that holds these numbers. The size of the array is the numbers read.

  • it is matlab coding Generate a 2 x 3 matrix of uniformly distributed random , real...

    it is matlab coding Generate a 2 x 3 matrix of uniformly distributed random , real numbers, each in the range (0, 1] real numbers, each in the range (4, 10) integer numbers, each in the inclusive range from 1 to 10 integer numbers, each in the inclusive range from 5 to 20

  • Integer Math- Console based---uses Windows Form in Visual Basic   Create an application that uses random integers...

    Integer Math- Console based---uses Windows Form in Visual Basic   Create an application that uses random integers to test the user’s knowledge of arithmetic. Let the user choose from addition, subtraction, multiplication, and division. The integers used in the problems should range from 20 to 120. When giving feedback, use color to differentiate between a correct answer response, versus an incorrect answer response. Also check for non-integer input. Preparing division problems requires special consideration because the quotient must be an integer....

  • Part 2 -Arrays We can use the Math.random method to generate random integers. For example, Math.r...

    Please write a JAVA program according to following requirement. Thanks Part 2 -Arrays We can use the Math.random method to generate random integers. For example, Math.random () generates a random integer greater than or equal to 0 and less than 1. The expression Math. random) 6generates random numbers between 0 and 5, simulating the throw of a die. In this lab assignment, you will use an array to test whether the random generator is fair; that is, whether each possible...

  • Python: Write a func that will create a list of random numbers. The function will take...

    Python: Write a func that will create a list of random numbers. The function will take in two parameters. The first parameter specifies how many values to generate and the second parameter is the highest random # (2 is the minimum) that the func generates. To get the random numbers, you may use this line of code: y = random.randint (2,max), where max is the highest possible random #, INCLUSIVE.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT