1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andrew [12]
3 years ago
7

. Write Java statements to instantiate a random number generator object and generate a random integer between 100 and 250 (inclu

sive).
Computers and Technology
1 answer:
Umnica [9.8K]3 years ago
6 0

Answer:

//import Random package

import java.util.Random;

class Main

{

public static void main (String[] args) throws java.lang.Exception

{

   try{

    /* create an object of Random class. this will generate random number

    in a given range. */

       Random rand = new Random();

       // create two variables and assign 100 and 250 to

       int l = 100;

       int h = 250;

       //generate the random number between 100 & 250 (inclusive)

       int ran_num = rand.nextInt((h+1)-l) + l;

       System.out.println("random number is: "+ran_num);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Import "import java.util.Random" package.In this package, Random class exist. With the help of this class's object, we can generate a random number between a given range.Here we have to generate a random number between 100 to 250(inclusive). So "(h+1)-l" will be 151 and the number generate is in the range of 0-150. if we  add 100 to it, then random number will be in range of 100 to 250.

Output:

random number is: 158

You might be interested in
Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a pers
GuDViN [60]

Answer:

<em>This program is written using C++</em>

<em>Comments are used to explain difficult lines</em>

<em>Program starts here</em>

#include<iostream>

using namespace std;

int main()

{

//Declare variables

float BMI, Height,Weight;

// Prompt user for inputs

cout<<"Ener Height (in inches): ";

cin>>Height;

cout<<"Enter Weight (in pounds): ";

cin>>Weight;

//Calculate BMI

BMI = (Weight * 703)/(Height * Height);

cout<<"Your Body Mass Index (BMI) is "<<BMI<<endl;

//Test and print whether user is underweight, overweight or optimal

if(BMI>=18.5&&BMI<=25)

{

 cout<<"You have an optimal weight";

}

else if(BMI<18.5)

{

 cout<<"You are underweight";

}

else if(BMI>25)

{

 cout<<"You are overweight";

}  

return 0;

 

}

<em>See attachment for .cpp source file</em>

Download cpp
6 0
3 years ago
What does no technical solution problems mean answers?
Lena [83]
Solve the problems to make every thing work perfect
4 0
3 years ago
Please Help!
tatyana61 [14]

Answer:

Its B,D,E

Explanation:

Got it right on e2020

5 0
3 years ago
_____ represents an entity in the real world that can be distinctly identified.
Margaret [11]

Answer:An object

Explanation: An objects play an important role as the  real world component/entity which display any element which are sourced through their behaviors and different states. Object are the entities that are required in the program for the making the program easier and simpler to understand .

Example- computer can be considered as the object which is related with the  real world.

4 0
3 years ago
Java provides a number of interfaces and classes to systematically implement collections.
solmaris [256]

Answer:

A) True

Explanation:

Java provides collections architecture or framework used to store and manipulate a group of objects or collections.

The collection framework has interfaces which include; Set, Queue, Deque, List, as well as classes which include; Hashset, ArrayList, LinkedList, LinkedHashset, PriorityQueue, Vector and TreeSet.

There are also many methods declared in the collection interface which include; add(), addAll(), remove(), removeAll(),retainAll(), clear(), size(), iterator(), toArray() etc

4 0
4 years ago
Other questions:
  • Write a program that reads the data from rawdata_2004.txt into a dictionary whose keys are country names and whose values are pe
    5·1 answer
  • Which of the following conditions will maximize the amount of interest you earn
    5·1 answer
  • Define a member function PrintAll() for class PetData that prints output as follows. Hint: Make use of the base class' PrintAll(
    8·1 answer
  • Explain by details operator overloading in C++ with example
    6·1 answer
  • __________ systems support the search for and sharing of organizational expertise, decision making, and collaboration at the org
    9·1 answer
  • Colby works as a shipping clerk for a major package delivery service. Some of his daily tasks include tracking shipments and ent
    7·2 answers
  • Versiones del Moodle
    10·1 answer
  • An intruder with malicious intent breaks into an office and steals a hard drive containing sensitive information about the compa
    5·1 answer
  • A large number of consecutive IP addresses are available starting at 198.16.0.0. Suppose that four organizations, Able, Baker, C
    11·1 answer
  • Assume we have two lists, list A and list B. List A contains the numbers [20,10,20], while list B contains the numbers [40,10,30
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!