Declare an array of type int named datapoints

Assignment Help JAVA Programming
Reference no: EM132430736

We use java.util.Random() to generate random numbers. We have to include the import:

import java.util.Random;

Create a random object:

Random rnd = new Random();

int val = rnd.nextInt(100);  // gives a value from 0 to 99

int val = rnd.nextInt(100) + 1; // gives a value from 1 to 100

int index = rnd.nextInt(myArray.length); gives a random valid index on myArray

Begin the lab:

Create a netbeans project called ArrayStuff with a single java main class also called ArrayStuff. All the code for the lab you will do today is in this single main class. Implement each problem in the main class and test it carefully as you go.

  1. Declare an array of type int named dataPoints.
  2. dataPoints should have a length of 100. (i.e. it should hold 100 int values.)
  3. Now, code a regular for loop that iterates through the dataPoints array and initializes each element in it to a random value between 1 and 100.
  4. (See notes above for using java.util.Random. Please do not use Math.Random!)
  5. Code a second loop that displays the dataPoints values like this (values are all on the same line and separated by " | " e.g. space, vertical bar, space):
  6. val1 | val2 | val3 | HINT: use printf or System.out.print()

Now code a loop that calculates the sum and the average of the values in dataPoints. Add code to output/display the sum and the calculated average. (Be sure to include some sort of description in the output so it is clear (i.e. use complete sentences) : 'The average of the random array dataPoints is: ' or something similar. Don't just print out the average and sum as a raw numbers.

After the first step I am confused on how to set up the different for loops

Reference no: EM132430736

Questions Cloud

What are differences of dominant culture in family history : How does your family history reflect the similarities and differences of the dominant culture? What do these similarities and differences mean
How your workforce has responded to the change : Select one of the four challenges and expand on how your workforce has responded to the change. How have these challenges affected the access to care for your.
Installing the server with default settings : Improper file or directory permissions, installing the server with default settings, unnecessary services enabled, security conflicts,
Write an essay discussing the purnell model its framework : Please present an essay discussing the Purnell model its framework, assumptions which the model is based and how this model helps us to provide cultural.
Declare an array of type int named datapoints : Declare an array of type int named dataPoints. dataPoints should have a length of 100. (i.e. it should hold 100 int values.)
Prepare an effective-interest amortization table : Premiere Auto-parts Inc. issued $190,000 of 7%, 10-year bonds at a price of 83 on January 31, 2017. Prepare an effective-interest amortization table
Ethical hacking : There are many mobile platform vulnerabilities listed in the readings from previous lessons. Which do you feel is the greatest threat to users?
What are the attributes of our system : Select three other attributes of our system and relate them to these three pillars. You may use the attributes provided by Shi and Singh for your selection.
Do you feel the benefits of cloud computing : Do you feel the benefits of cloud computing are worth the threats and vulnerabilities?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a very simple java program

Create a Java program with file name of greetings.java. Your program will provide a short introduction about yourself: name, the city you live in, hobbies etc

  Design a boolean function named isprime,

A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Des..

  Display the values that were typed in to the form

This assignment will focus on creating Java Server Pages (JSP) and deploying them onto a Java Servlet Container.

  Write an application that displays all even numbers

Write an application that displays all even numbers from 2 to 100 inclusive, and that starts a new line after every multiple of 20 ( 20, 40, 60, and 80). Save the file as EvenNums. java

  Create a program that keeps track

Create a program that keeps track of specific information for Students. The information stored should be the following: First Name, Last

  Implement a simple annual expense estimator

MIST.3050 Business Applications Development - implement a simple "Annual Expense Estimator" to tabulate your expense items. Expenses are an important component

  Java program which defines an unconstrained array

Write a Java program which defines an unconstrained array of user defined length n, that contains n Random numbers and outputs those random numbers that are even numbers

  Call the method printwinpercentage

Call the method printWinPercentage with the player's name, the first year of play and the array - There should be three parameters: a String for the players

  Determine the example of a javascriptr framework in the

what is an example of a javascriptr framework? in the framework you have described what is an example of an application

  Information about the gardening tools

You need to store information about the gardening tools that you sell in your online store. To do so, you maintain a list of product records

  Define an adt for character strings.

Define an ADT for character strings. Your ADT should consist of typical functions that can be performed on strings, with each function defined in terms of its input and output. Then define two different physical representations for strings.

  Implement a vending machine simulator

Create a new multi-class Java program which implements a vending machine simulator which contains the functionality

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