design and implement a method numberfreq() that takes no parameters. the method reads an arbitrary number of integers that are in the range 0 to 20 inclusive and counts how many occurrences of each are entered. the method employs an array to store the frequencies and returns this array. 2. write a method bigeven () that takes two parameters: an integer array, numberarr, and an integer, target. the method returns the number of integers in the array that are even and bigger than target. 3. write a method odddice() that takes an array of die objects as a parameter. the method rolls each die and returns the total number of dice that land in an even face value. 4. embed the methods 1-3 in an application, testarrays. the application invokes each method using simple test cases and displays the results. for example, invoke method bigeven() using an array containing integers: 2, 7, 8, 3, 4, 10 and a target 4 and print the result value (2).

Respuesta :

Using knowledge in computational language in JAVA it is possible to write a code that design and implement a method numberfreq() that takes no parameters. the method reads an arbitrary number of integers.

Writting the code:

import java.util.Arrays;

import java.util.Scanner;

//Die class

class Die

{

private int face;

public Die()

{

face=0;

}

public void roll()

{

face=(int)(Math.random()*6+1);

}

public int getface()

{

return face;

}

}

public class TestArrays

{

public static void main(String[] args)

{

//1.Testing numberFreq method

//call numberFreq method

int freq[]=numberFreq();

for (int i = 0; i < freq.length; i++)

{

if(freq[i]!=0)

System.out.printf("%-10d%-10d\n", i+1, freq[i]);

}

//2. Testing bigEven method

int numArray[]= { 2, 7, 8, 3, 4, 10};

int target=5;

System.out.println("Array : "+Arrays.toString(numArray));

System.out.println("Target: "+target);

int count=bigEven(numArray, target);

System.out.println("Count of even elements and greater than target is "+count);

//create an array of 50 Die variables

Die[] dieobjects= new Die[50];

//3. Testing oddDice method

System.out.println("Count of odd dice is "+oddDice(dieobjects));

}

/*Method oddDice takes an array of Die variables

* and returns the number of dice land in odd faces as return value*/

public static int oddDice(Die dices[])

{

int oddfacedices=0;

for (Die die : dices) {

//create object of Die class

die=new Die();

die.roll();

if(die.getface()%2==1)

oddfacedices++;

}

return oddfacedices;

}

/*

* The method bigEven takes an array of integer and target

* and returns the number of even values that are greater than target

* as retunr value.

* */

public static int bigEven(int numArray[] , int target)

{

int counter=0;

for (int i = 0; i < numArray.length; i++)

{

if((numArray[i]%2==0) &&(numArray[i]>target))

counter++;

}

return counter;

}

public static int[] numberFreq()

{

Scanner sc=new Scanner(System.in);

int[] freq=new int[50];

int x=0;

do

{

System.out.printf("Enter a number in range of 0 - 50 or 999 to exit:");

x=Integer.parseInt(sc.nextLine());

if(x!=999)

freq[x-1]++;

}while(x!=999);

return freq;

}

}

See more about JAVA at brainly.com/question/18502436

#SPJ1

Ver imagen lhmarianateixeira