JAVA Write code that asks for a positive integer n, then prints 3 random integers from 2 to n+2 inclusive using Math. Random().

Note #1: In the starter code for this exercise the line "import testing. Math;" appears. You should not remove this line from your code as it is required to correctly grade your code. Also make sure that your code outputs exactly 3 numbers (be particularly careful there aren't any extra numbers in your prompt for user input).

Note #2: Make sure your minimum output is 2 or more and make sure your maximum output is only up to n + 2 (so if user inputs 5, the maximum output should only be 7). Hint: Knowing your PEMDAS will help a lot.

Sample Run: Enter a positive integer: 6 7 2 5

Respuesta :

The program for the positive integer is illustrated thus:

/*Importing Necessary Classes*/

import java.util.*;

/*Note : Comment This Line Of Code If you Want to Run the Code in your IDE*/

import testing.Math;/*Note : Comment This Line Of Code If you Want to Run the Code in your IDE*/

/*Note : Comment This Line Of Code If you Want to Run the Code in your IDE*/

/*Declaring A Public Class*/

public class Main{

   

   /*Declaring Main Method Execution Starts From Here*/

   public static void main(String[] args){

       

       /*Declaring a startFrom int Variable to Store the starting value*/

       int startFrom = 2;

       

       /*Declaring a endAt int Variable to Store the End Value value*/

       int endAt;

How to illustrate the program?

We first import the necessary classes that will be utilized by the program.

We must now declare the Main class as a public class. Execution begins after declaring a Main Method inside the Public Main Class.

Next, declare an int variable called startFrom to store the starting value.

Next, create an int variable named endAt to store the end value. Next, declare an int variable named randomNumber to hold the random value. Here, creating a Scanner Class object to receive input from the user

Learn more about program on:

https://brainly.com/question/26642771

#SPJ1