Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use jGRASP to complete the following programs and understand what they do. //************************************************************************************************************ //RandomNumbersImproved.java Author: Lewis/Loftus // Demonstrates the cration of pseudo-random numbers using Random

Use jGRASP to complete the following programs and understand what they do. //************************************************************************************************************ //RandomNumbersImproved.java Author: Lewis/Loftus // Demonstrates the cration of pseudo-random numbers using Random class. // *********************************************************************************************************** import java.util.Ranom; public class RandomNumbersImproves { // ----------------------------------------------------------------------------------------------------------------------- // Generates random numbers in various ranges. // ----------------------------------------------------------------------------------------------------------------------- public static void main (String[] args) { Random generator = new Random(); int num1; int min = 0; int max = 9; double num2; num1 = generator.nextInt(); System.out.println("A random integer: " + num1); num1 = min + generator.nextInt((max-min) + 1); System.out.println("From 0 to 9: " + num1); min = 1; max = 10; num1 = min + generator.nextInt((max - min) + 1); System.out.println("From 1 to 10: " + num1); min = 20; max = 34; num1 = min + generator.nextInt((max-min) + 1); System.out.println("From 20 to 34: " + num1); min = -10; max = 9; num1 = min + generator.nextInt((max - min) + 1); System.out.println("From -10 to 9: " + num1); min = 1; max = 6; num2 = (double)min + generator.nextDouble() * (double)((max-min) + 1); //1.0 to 6.99999999999 num1 = (int)num2; System.out.println("From 1 to 6: " + num1); min = 0; num2 = (double)min + generator.nextDouble() * Math.nextUp(double)((max - min) + 1); //0.0 to 6.0 System.out.println("From 0.0 to 6.0: " + num2);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

state what is meant by the term performance management

Answered: 1 week ago