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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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