JAVA, Please do as asked and show solution/code clearly and let code ready to be copied: complete the remaining exercises as methods within that class
Write a Java method that: - takes as input parameter a 2D array of numbers, with R rows and C columns - and fills the array following the next rule (for R = 3 and C = 5): [[1, 2, 3, 4, 5] [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]] - print array within method - void return Test it by creating an empty 2D array in main and calling this method on that array.
Write a Java method that: - takes as input a 2D array of numbers - and returns the number of even elements in the array - e.g. If the input 2D array is [[1, 2, 3] [4, 5, 5] [2, 7, 1]], the output should be 3 (because 2, 4, 2 are even) Test your method by calling it from the main method using a user defined array. Print the number of even elements on screen.
Write a Java method that: Method name: swapArray - takes as input a 2D array of numbers and 2 row indices R1 and R2 - and swaps the row R1 with the row R2 from the array - e.g. If the input 2D array is 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 - and R1 = 1 and R2=3, then the output should be: 1 1 1 1 4 4 4 4 3 3 3 3 2 2 2 2 Test your method by calling it from the main method using a user defined 2D array. Print the array content before and after the method call.
public class ArrayTest {
public static void fillArray(int arr[][], int r,
int c) {
for (int i = 0; i < r; i++)
{
for (int j = 0;
j < c; j++)
arr[i][j] = j + 1;
}
}
public static void printArray(int arr[][], int r,
int c) {
for (int i = 0; i < r; i++)
{
for (int j = 0;
j < c; j++)
System.out.print(arr[i][j]+" ");
System.out.println();
}
}
public static int evenCount(int arr[][], int r, int
c) {
int count = 0;
for (int i = 0; i < r; i++)
{
for (int j = 0;
j < c; j++)
if (arr[i][j] % 2 == 0)
count++;
}
return count;
}
public static void swapRow(int arr[][], int r1, int
r2) {
int count = 0;
for (int i = 0; i <
arr[r1].length; i++) {
int temp =
arr[r1][i];
arr[r1][i] =
arr[r2][i];
arr[r2][i] =
temp;
}
}
public static void main(String[] args) {
int arr[][]=new int[3][5];
fillArray(arr, 3, 5);
printArray(arr, 3, 5);
System.out.println("Even numbers
count "+evenCount(arr, 3, 5));
}
}

JAVA, Please do as asked and show solution/code clearly and let code ready to be copied:...
by netBeans C++ java
by netBeans C++ java
by netBeans C++ java
1. Answer the following question a) (4 marks) Write a Java method, which takes an integer array and two integers x and y as input parameters. The method should exchange the value in position x with the value in the position y in the array. Example: If x = 1, y=2 Input Array Output Array b) (4 marks) Write the main method to do the following: 1. Define...
C# Code please with picture of code.Thanks! 1. Create a Main method, and create a 2D integer array called data, with a size of five (5) by five (5). Ask the user to input the values for this array (Scanner’s nextInt) 2.Create a method called LongestPositiveSeries, that takes in a 2D array and finds the length of the longest continuous series of positive numbers in it. For example, if we had an array like this: 0 1 2 3 4...
Below is my code and the instructions for the code. I can't figure out what's wrong. Please help. Tasks This lab has two parts: Writing a searching function for 1D arrays. Writing a simple class. Part 1 – Searching Continuing with arrays, we will now expect you to find information in an array and derive useful properties from the information stored in an array. Start Eclipse. Change the workspace directory location to something "safe". You may want to temporarily choose...
//please help
I can’t figure out how to print and can’t get the random numbers to
print. Please help, I have the prompt attached. Thanks
import java.util.*;
public
class
Test
{
/**
Main method */
public
static
void main(String[]
args)
{
double[][]
matrix
=
getMatrix();
//
Display the sum of each column
for
(int
col
= 0;
col
<
matrix[0].length;
col++)
{
System.out.println(
"Sum
" + col
+
" is
" +
sumColumn(matrix,
col));
}
}
/**
getMatrix initializes an...
Need code written for a java eclipse program that will follow
the skeleton code.
Exams and assignments are weighted
You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...
This is the contents of Lab11.java
import java.util.Scanner;
import java.io.*;
public class Lab11
{
public static void main(String args[]) throws IOException {
Scanner inFile = new Scanner(new File(args[0]));
Scanner keyboard = new Scanner(System.in);
TwoDArray array = new TwoDArray(inFile);
inFile.close();
int numRows = array.getNumRows();
int numCols = array.getNumCols();
int choice;
do {
System.out.println();
System.out.println("\t1. Find the number of rows in the 2D
array");
System.out.println("\t2. Find the number of columns in the 2D
array");
System.out.println("\t3. Find the sum of elements...
java programming!!!
Write the code fragment that will do the following: • Ask the user how many numbers they want to enter • Declare and instantiate an array of doubles with as many elements as the number entered by the user • Write one 'for' loop to fill the array with data from the user • Write a second 'for' loop to calculate the sum of all of the numbers in the array • Print the calculated sum Note: Write...
11) Write a method (including header and body) that takes as an input an array of doubles and f three doubles containing the average, the maximum and the minimunm values of the input array. Test the program by calling the method from the main method. For example Input: 1 2 3 45 Output: 3 5 1 12) Write a Java method that takes a string as an argument and returns the reverse the string. Test the program by calling the...
This is java. Please let me know about those code. Please do not use array and scanner. Just do by loop. // a) Task: Find the sum of all multiples of 3 and 5 less than 1000. // b) Task: Given two integers k and n, print out every multiple of k less than n // c) Task: Given an integer n, print out k^k for every k=1...n // d) Task: Write a function called "factorProduct" that takes as input...
Please complete this code for java
Lab Write a program as follows: Create an array with 10 elements. The array should contain numbers generated randomly between 1 and 100 Ask the user to enter any number - Search the array to see if the user entered number is in the array If the user-entered number is in the array, print a 'match found' message. Also print at which index the match was found, else print a 'match not found' message...