Question

Write program to generate random numbers in different range and display: (c) A number in range...

Write program to generate random numbers in different range and display: (c) A number in range [0, 10) (d) A number in range [0, 1000] (e) A number in range [-99, 99] (f) A double number in range [1000.0, 9999.0)

In Java Please

Homework Answers

Answer #1
import java.util.Random;

public class RandomNumbers {

    public static void main(String[] args) {
        Random random = new Random();
        int c = random.nextInt(10);
        int d = random.nextInt(1001);
        int e = random.nextInt(199) - 99;
        double f = 1000 + random.nextDouble() * 8999;

        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
        System.out.println(f);
    }
}

Know the answer?
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
Similar Questions
Randomly generate an integer number in range [10, 99]. Write a program to check if the...
Randomly generate an integer number in range [10, 99]. Write a program to check if the digit at 10’s position is less than the digit at 0’s position. If yes, swap these 2 digits. Display original number and new number. For example, if the number generated is 53, after process, the new number will be 35. If original number is 12, no process needed. If the number is 50, the new number will be 5. in Java please
In Java : Randomly generate an integer number in range [10, 99]. Write a program to...
In Java : Randomly generate an integer number in range [10, 99]. Write a program to check if the digit at 10’s position is less than the digit at 0’s position. If yes, swap these 2 digits. Display original number and new number. For example, if the number generated is 53, after process, the new number will be 35. If original number is 12, no process needed. If the number is 50, the new number will be 5.
Write a java program to display a given range of integer numbers (0 to 9) in...
Write a java program to display a given range of integer numbers (0 to 9) in the following order: Example : given (5 to 9), the program displays 56789 67895 78956 89567 95678 The first line displays the min to max range. Each line that follows should display the next higher number except when it hits the maximum number. In that situation, the line wraps back to the minimum sequence. For this problem write a static method to do the...
The programmer intends for this pseudocode to display three random numbers in the range of 1...
The programmer intends for this pseudocode to display three random numbers in the range of 1 through 10. Locate the error and clearly explain the error. // This program displays three random numbers in the range of 1 through 10. Declare Integer count Declare Real value // Display three random numbers. For count = 1 To 5 Step 2 Set value = count Display random(10, 1) End For
In C++ Write a simple program to generate random integers between X and Y and store...
In C++ Write a simple program to generate random integers between X and Y and store them in a file, one number per line. The user should input the number of elements to generate and the boundary numbers X and Y (e.g. the inputs 100, 0, 999 mean your program should generate a list of 100 integers with values between 0 and 999, inclusive).
Meant to be written in Java JDK 14.0 Generate four (4) integer numbers in range [0,...
Meant to be written in Java JDK 14.0 Generate four (4) integer numbers in range [0, 100]. Use Math methods to: (a) find the maximum and minimum numbers and display (b) calculate the absolute difference between the maximum number and minimum numbers, display
Randomly generate an integer number in range [1, 999], (a) Check if this number is even...
Randomly generate an integer number in range [1, 999], (a) Check if this number is even or odd, display message “[number] is an even number” or “[number] is an odd number”. For example, if the number is 10, display message “10 is an even number”. (b) Check if this number is divisible by 7 and 11. Display message showing result (c) Check if this number is divisible by 9 or 13. Display message showing result (d) Check if this number...
write a C++ program that display a prime numbers between 1 and 100 number. Plase print...
write a C++ program that display a prime numbers between 1 and 100 number. Plase print the remaining primes by “dots” For gexample The output should appear like The prime numbers between 1 and 100 are: 1, 2, 3, 5, 7, .........
Write a C++ program that simulates flipping a coin (random numbers) 1000 times and displays the...
Write a C++ program that simulates flipping a coin (random numbers) 1000 times and displays the number of heads and tails. Note that there is no input to the program and the number of heads and tails will be around 500.
Write a complete program that will generate equally likely random shoe sizes in the inclusive range...
Write a complete program that will generate equally likely random shoe sizes in the inclusive range [5, 13.5], with whole or half sizes allowed. The number of values to generate will be input by the program user. It will also count and display the total number of times small (5, 5.5, 6, 6.5) and large (12, 12.5, 13, 13.5) sizes are generated. We have provided skeleton code for you to use. You must implement the helper method as given in...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT