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)
|
0 |
1 |
2 |
3 |
4 |
|
5 |
-1 |
-5 |
-5 |
5 |
|
3 |
-2 |
56 |
25 |
-15 |
|
0 |
5 |
5 |
0 |
324 |
|
46 |
25 |
0 |
0 |
0 |
Code -
using System;
public class MultiArrayExample
{
public static void Main(string[] args)
{
//2d array initialized
int[,] arr = { { 0, 1, 2, 3, 4 }, { 5, -1, -5, -5, 5 }, { 3, -2,
56, 25, -15 }, { 0, 5, 5, 0, 324}, { 46, 25, 0, 0, 0 }
};//declaration and initialization
//print the output return by LongestPositiveSeries function
Console.Write("Longest Positive Series:
"+LongestPositiveSeries(arr));
}
//function to return LongestPositiveSeries
public static int LongestPositiveSeries(int[,] arr){
//variable declare
int maxCount = 0,maxCountNow =0;
//iterate through array
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
//compare arr[] is less than 0
if(arr[i,j]<=0){
if(maxCount<maxCountNow){
maxCount = maxCountNow;
}
maxCountNow = 0;
}
//if arr[] is greater than 0
if(arr[i,j]>0){
maxCountNow++;
}
}
}
return maxCount;
}
}
Screenshots -

pls do give a like thank you
C# Code please with picture of code.Thanks! 1. Create a Main method, and create a 2D...
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...
Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...
Java : Please help me correct my code: create a single class (Program11.java) with a main method and some auxiliary methods to input a 2-D array from a disk file, input some “transactions” to change the 2-D array and output the changed 2-D array to another file. Your main method will be minimal (see below). Most of the work will go on in your methods. In main, declare (but do not instantiate) 2-D array. Then call the three methods. The...
Part 1- Method practice Create a main method. In there, make an array of 100 random integers(numbers between 0 and 1000). Create a method to find average of the array. Pass the array and return the number(double) that is the average In the main method, call the method created in Step 2. Print out the average Create a method to find the min value of the array. Pass the array and return the int that is the smallest.(pass the value...
The last element in each array in a 2D array is incorrect. It’s your job to fix each array so that the value 0 is changed to include the correct value. In the first array, the final value should be the length of the first array. In the second array, the final value should be the sum of the first value, and the second to last value in the array. In the third array, the final value should be the...
Assignment is designed to develop your ability to create static methods and manipulate 1D and 2D arrays in Java. Create a single Java class Matrix and inside the class create the specified static methods as described Task # Description 1 Create a matrix (known components) 2 Create a matrix (random components) 3 Create a matrix from vectors 4 Compare two matrices 5 Add two matrices 6 Subtract two matrices 7 Multiply a matrix by a scalar 8 Multiply two matrices...
Step 1. Start Netbeans and create a project called ArrayLab Step 2. Write the main method Declare and initialize an array called myNums int myNums = {3, 8, 12, 4, 2, 9, 6}; Declare an int called largestNum and set it to 0. Write a for loop that prints the array for (int index = 0; index < myNums.length; index++) { System.out.println(myNums[index] + “ “); } Write a for loop that prints the array backwards ...
Write code in static void main method class, which creates a boolean array called flags, size 10, and using a for loop sets each element to alternating values (true at index zero, false at index one Write code in a static void main method class, which creates a float array called sales, size 5, uses an initializer list to instantiate its elements with positive values having two decimal places (example 7.25), and using a for loop reads those values of...
Java programming: I need to create a method that is given a 2D char array and a String that returns a part of the original 2D array. The input string will tell the method which rows from the input array need to be returned. For example, a 5x5 char array input along with a string "0 4" would return rows 1 and 5 of the input array. The String input will always be numbers divided by spaces and will not...
Please code in C thank you.
1. Create an array with 20 random numbers between 1 and 100. Incorporate the following specifications. • Send the base address of the array and an integer to a function called sort(). • The integer is a user input which is either 0 or 1. If the user does not enter either 0 or 1, keeping asking the user until you get the right input. • If the user input is 0, sort the...