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
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.
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...
Using the Java language program Demonstrate multiway if statement 1.1 Generate an integer random number from...
Using the Java language program Demonstrate multiway if statement 1.1 Generate an integer random number from -5 to 5.(Hint: Use Math.random()) 1.2 Write a multiway if statement that will display whether the number is positive, negative or zero. 1.3 Be sure to test your code with all three cases
1- Write a program to print only the even numbers from 100 to 200 2- Write...
1- Write a program to print only the even numbers from 100 to 200 2- Write a program to print the odd numbers from 22 – 99 3- Write a program to calculate howe many even number from 10 to 120 1- Write a program to find only the even numbers for 12 different numbers 2- Write a program to find the odd numbers for 10 different numbers 3- Write a program to calculate howe many even number and how...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT