So this is all I have done
right now. Next steps:
1. Create a method called "printArray" which would put the code
: for(int i = 0; i < myArray.length; i++)
System.out.println(myArray[i]); at the bottom of that screen and
put it into a method and then call it.
2. Create another method thats going to count all the numbers that are evenly divisible by 10 and call the method whatever you like.
* Just make sure to return, pass at the array, and return how many numbers are evenly divisible by 10.
import java.util.Random;
public class JavaApplicaton36 {
public static void main(String[] args) {
// this is not a valid line, as the
Consol() is Private constructor
//Console c = new Console()
JavaApplicaton36 j = new
JavaApplicaton36();
int[] myArray =
j.creaArray(10);
printArray(myArray);
System.out.println("Numbers evenly
divisable by 10 : " + count(myArray));
}
//counts the number of elements that are diviable
by 10
private static int count(int[] myArray) {
int count = 0;
for (int i = 0; i <
myArray.length; i++)
if (myArray[i] %
10 == 0)
count++;
return count;
}
// Prints the elements to the console
private static void printArray(int[] myArray) {
for (int i = 0; i <
myArray.length; i++)
System.out.println(myArray[i]);
}
// creates the array with given size using random
number
private int[] creaArray(int aI) {
//creating array
int arr[] = new int[aI];
//creating random object
Random r = new Random();
//looping to fill the array
for (int i = 0; i < arr.length;
i++)
arr[i] =
r.nextInt(101);
return arr;
}
}
![E Console 3 terminated> JavaApplicaton36 Java Application] C Soft PegaEclipse-win64-4.5.2.2Peg 36 45 65 57 72 19 56 Numbers e](http://img.homeworklib.com/images/0925ac09-ff9c-4a6e-83d0-cef6b213c13b.png?x-oss-process=image/resize,w_560)
So this is all I have done right now. Next steps: 1. Create a method called "printArray" which wo...
PrintArray vi Create a class called PrintArray. This is the class that contains the main method. Your program must print each of the elements of the array of ints called aa on a separate line (see examples). The method getArray (included in the starter code) reads integers from input and returns them in an array of ints. Use the following starter code: //for this program Arrays.toString(array) is forbidden import java.util.Scanner; public class PrintArray { static Scanner in = new Scanner(System.in);...
need help editing or rewriting java code, I have this program
running that creates random numbers and finds min, max, median ect.
from a group of numbers,array. I need to use a data class and a
constructor to run the code instead of how I have it written right
now. this is an example of what i'm being asked
for.
This is my code:
import java.util.Random;
import java.util.Scanner;
public class RandomArray {
// method to find the minimum number in...
In this same program I need to create a new method called “int findItem(String[] shoppingList, String item)” that takes an array of strings that is a shopping list and a string for an item name and searches through the “shoppingList” array for find if the “item” exists. If it does exist print a confirmation and return the item index. If the item does not exist in the array print a failure message and return -1. import java.util.Scanner; public class ShoppingList...
my goal is to generate a random number every 10 seconds and store in arraylist. when I generate the new number every 10 second I want to update the previous number from the arraylist. currently it gets the first current number in main method but when I store after 10 second i'm not getting the update current number. I would appreciate any help. NOTE: ***I want the Runnable to be in the same class, Not in main method. my goal...
my goal is to generate a random number every 10 seconds and store in arraylist. when I generate the new number every 10 second I want to update the previous number from the arraylist. currently it gets the first current number in main method but when I store after 10 second i'm not getting the update current number. I would appreciate any help. NOTE: ***I want the Runnable to be in the same class, Not in main method. my goal...
. In the method main, prompt the user for a non-negative integer and store it in an int variable num (Data validation is not required for the lab). Create an int array whose size equals num+10. Initialize the array with random integers between 0 and 50 (including 0 and excluding 50). Hint: See Topic 4 Decision Structures and File IO slides page 42 for how to generate a random integer between 0 (inclusive) and bound (exclusive) by using bound in...
I need to program 3 and add to program 2 bellows: Add the merge sort and quick sort to program 2 and do the same timings, now with all 5 sorts and a 100,000 element array. Display the timing results from the sorts. DO NOT display the array. ____________________>>>>>>>>>>>>>>>>>>>>___________________________ (This is program 2 code that I did : ) ---->>>>>> code bellow from program 2 java program - Algorithms Write a program that randomly generates 100,000 integers into an array....
Hi,
So I have a finished class for the most part aside of the toFile
method that takes a file absolute path +file name and writes to
that file. I'd like to write everything that is in my run method
also the toFile method. (They are the last two methods in the
class). When I write to the file this is what I get.
Instead of the desired
That I get to my counsel. I am
having trouble writing my...
Question: Modify the Rectangle and Box classes that are below, so that they implement the Comparable interface. The compareTo() method shall compare rectangles and boxes by areas and volumes. In main(), create an ArrayList of rectangles and an ArrayList of boxes. Randomly generate ten rectangles and ten boxes adding to the two ArrayLists. Use Collections.sort() to sort the two ArrayLists, respectively. Print the ArrayLists before and after being sorted. Three classes that need to be edited are below: Main class,...
For this assignment, your job is to create a simple game called
Opoly.
The objectives of this assignment are to:
Break down a problem into smaller, easier problems.
Write Java methods that call upon other methods to accomplish
tasks.
Use a seed value to generate random a sequence of random
numbers.
Learn the coding practice of writing methods that perform a
specific task.
Opoly works this way: The board is a circular track of variable
length (the user determines the...