Generate a random number


Tuesday, October 31, 2023 Difficulty: Easy

Objective

Create a Java program that prompts the user for 2 integers and displays a random number on the screen between those values.

Input

1
3

Output

3

Solution

Click here to view the exercise solution

Share it

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

Copied

The code has been successfully copied to the clipboard.

More Exercises

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

1

Variables

Variables are an essential component in any programming language, and Java is no exception. In this post, we will explore the concept of variables in Java and how they are used in programming.

2

Fundamentals of data types

Data types are a fundamental concept in programming and play a crucial role in Java, a strongly typed programming language. In this section, we will explore the basic concepts of data types in Java and their importance in application development.

3

Primitive data types

Primitive data types in Java are fundamental elements that represent simple values and are used to store basic data.

4

Wrapper classes

In Java, wrapper classes are a set of classes that encapsulate primitive data types.

5

Reverse chars

Write a program to ask the user for three letters and display them in reverse order.

6

Double value

Write a Java program that requests the width (x) and height (y) of a rectangle and calculate the perimeter, area and diagonal.

7

Float value

Create a program Java to ask the user for a distance in meters and the time taken (hours, minutes, seconds).

8

Generate a random number

Create a Java program that prompts the user for 2 integers and displays a random number on the screen between those values.

Data types

Practice with easy and intermediate Java exercises on different types of text, numeric or boolean data.

Fundamentals concepts
Practice exercises

Keep learning

C# Programming Course

Free programming course with practical exercises and solutions in C#. Start learning right now!

Exercises C# App

Take your Exercises C# lessons everywhere with our Android app. Download it now from Google Play