Prepare a new int[] variable and inititialize it

Assignment Help C/C++ Programming
Reference no: EM13707287

Program: public static int[] random(int size, int min, int max)

This method takes three integers and then creates and returns a new int array with size given by the size argument and filled with random values in the range [min, max].

Prepare a new int[] variable and inititialize it to be a new int array with the given size to create random values use the random class import javautil.random inside the method create a new instance with: Random rand = new Random();

The loop through the indexes of the array you created and fill them with a random number between min and max to generate a random number between min and max use random.nextINt(max-min+1) + min

Return now to the filled in array after the loop, to return an array, just return the name of the array, like for all the other variables.

You have to create and return a new int array with size. I am stuck on how to put the dashes in correctly.

Reference no: EM13707287

Questions Cloud

Program that will call a function called writedatatofile : Write a program that will call a function called writeDataToFile to prompt a user for their first name, last name and zip code, and print this information to a file called "UserData.txt".
Find the sum and difference for numbers : Write a program that prompts the user for two numbers, finds the sum and difference for those numbers and displays a descriptive label for each computation by calling two different functions. Use Function Prototypes.
What does the execute bit mean for a directory : What does the 'execute' bit mean for a directory? Show how the execute bit works for referencing files within directories. Does the execute bit need to be set for ANY directory on the path to a file you wish to reference?
Representing an investment value and interest rate : Write a Java test program, all your code should be in the main method that asks the user for two numbers representing an investment value and interest rate.
Prepare a new int[] variable and inititialize it : Prepare a new int[] variable and inititialize it to be a new int array with the given size to create random values use the random class import javautil.random inside the method create a new instance with: Random rand = new Random();
What is a data model and what is it purpose : What is a data model and what is it purpose and what is a prototype and what is its purpose - What is a use case, and what is its purpose?
Can you find the element of an array : We would like to determine whether a given array A has a majority element, and if so, find the element.
Prepare a program that takes the data from triangle : Prepare a program that takes the data from triangle.txt (supplied in this folder) and outputs a message indicating whether the triangle is a right triangle. The text file has data for three triangles.
Explain exothermic reaction that is nonspontaneous : Question- Which of the following is consistent with an exothermic reaction that is nonspontaneous at high temperatures?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program that allows a user to enter 12 double values

Write a program that allows a user to enter 12 double values representing store sales for each month of one year. After all 12 values are entered,

  The main function should prompt the user

The main function should prompt the user for the 2 numbers, call the function to display the correct label, then calculate and display the sum of the numbers. Call the function to display the correct label, then calculate and display the differenc..

  Use functional decomposition to solve

Use functional decomposition to solve this problem, and code the solution using functions wherever it makes sense to do so. Your program should check for invalid data such as nonpositive dimensions, number of rooms less than 1.

  Given the following test scores and grade equivalents

Given the following test scores and grade equivalents, write a function which is passed a score, and returns a letter grade based on the score entered. A number less than 0 or greater than 100 is invalid.

  Calculation the distance and time printed on the screen

After each calculation the distance and time printed on the screen and accumulated to the sum of the total distance and sum of the total time. The current destination should be saved as the old postion for the next calculation

  Write specifications for a method

Write specifications for a method that advances any given date by one day. Include a statement of purpose, pre- and post-conditions, and a description of the parameters.

  Creates a macro to calculate the area

Build a program that creates a macro to calculate the area of a circle using the formula area = pie x radius x radius. In the same program, prompt the user to enter a circle's radius. Use the macro to calculate the circle's area and display the re..

  Write a function named append that accepts three arguments

Write a function named append that accepts three arguments. The first two arguments passed to append are c-strings to be appended (the second c-string is appended to the first). The third argument passed should be the size of the character array ..

  Write a program that convert fahrenheit to degrees celsius

Write a program that will convert Degrees Fahrenheit to Degrees Celsius.

  Square root of a number n

USING C++ the square root of a number N can be approximated by repeated calculation using the formula NG=.5(LG+N/LG) where NG stands for next guess and LG stands for last guess

  Compound operators or arithmetic assignment operators

Rewrite the given assignment statement using a combined assignment operator: (Use single spaces between operands and operators)

  Write a c++ program that prompts the user for a double

Write a C++ program that prompts the user for a double that is either positive or negative.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd