in java
/ You will:
// 1- create a square 2 dimensional array of random size (less than 11)
// 2- fill the array with random integers from 1 to the size limit
// 3- print the array
// 4- prompt to see if the user wants to do another
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 1- The square can use the same random value for x and y. Don't allow 0 size arrays.
// 2- Maybe a nested set of for loops? to go from row(0) col(0) to row(x)col(x)
// So that the values in the array aren't huge keep them limited to a range set by the number of values in a row (size){ A 6x6 square will contain integers smaller than 7, a 3x3 square will have integers smaller than 4}
// 3- Print it in the square format (On screen it will look like a rectangle but as long as the number of rows and columns are the same we will consider it a square.
// 4- If you used a Do loop to start the square the While condition could be held to check a sentinel the user enters as “yes”.
//Program
========================================================
import java.util.Scanner;
class Array2d{
static int[][] createArray(int x,int
y){
int arr[][]=new
int[x][y];
for(int
i=0;i<x;i++){
for (int k=0;k<y;k++){
arr[i][k]= (int) Math.round(Math.random()*(x-1))+1;
}
}
return arr;
}
static void display(int[][] arr,int x,int
y){
for(int
i=0;i<x;i++){
for (int k=0;k<y;k++){
System.out.print(arr[i][k]+" ");
}
System.out.println();
}
}
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
String choice="";
do{
int x = (int) Math.round(Math.random()*9)+1;
int y = (int) Math.round(Math.random()*9)+1;
System.out.println(x+" "+y);
int arr[][]= createArray(x, y);
display(arr, x, y);
System.out.print("Wants to do another(yes/no) : ");
choice = sc.nextLine();
}while(choice.compareTo("yes")==0);
}
}
====================================================
//output


======================================================
please appreciate my effort to solve your problem by hit like button
and comment below in case having any doubt
in java / You will: // 1- create a square 2 dimensional array of random size...
Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This will be the 3x3 matrix. Then, input 3, 64-bit, floating-point values. This will be a single-dimensional array and is the vector. Your program will simply ask the user to enter matrix values. Remember, there are 9 of these, but they need to be stored into a 3x3 multi-dimensional array (row-major). Then, your program will ask for the vector values, which will be stored into...
create a new Java application called "Scorer" (without the quotation marks) that declares a two-dimensional array of doubles (call it scores) with three rows and three columns and that uses methods and loops as follows. Use a method containing a nested while loop to get the nine (3 x 3) doubles from the user at the command line. Use a method containing a nested for loop to compute the average of the doubles in each row. Use a method to...
The purpose of this problem is to sort a 2 dimensional array of characters. Specify the size of the array and input the array. If the array is longer than specified, output if it is larger or smaller. Utilize the outputs supplied in main(). Example supplied in 2 test cases. Input 3↵ 3↵ 678↵ 567↵ 456↵ Expected Output Read·in·a·2·dimensional·array·of·characters·and·sort·by·Row↵ Input·the·number·of·rows·<=·20↵ Input·the·maximum·number·of·columns·<=20↵ Now·input·the·array.↵ The·Sorted·Array↵ 456↵ 567↵ 678↵ Input 3↵ 5↵ Ted↵ Mary↵ Bobby↵ Expected Output Read·in·a·2·dimensional·array·of·characters·and·sort·by·Row↵ Input·the·number·of·rows·<=·20↵ Input·the·maximum·number·of·columns·<=20↵ Now·input·the·array.↵ The·Sorted·Array↵ Bobby↵...
IN JAVA Overview In this project you will implement a Java program that will print several shapes and patterns according to uses input. This program will allow the use to select the type (say, rectangle, triangle, or diamond), the size and the fill character for a shape. All operations will be performed based on the user input which will respond to a dynamic menu that will be presented. Specifically, the menu will guide the user to decide between different forms...
C++ ONLY!!! NOT JAVA. The standard deviation is calculated from an array X size n with the equation std=sqrt(sum((xi-mean)2/(n-1))) Sum the square of difference of each value with the mean. Divide that sum by n-1. Take the square root and you have the standard deviation. //System Libraries #include <iostream> //Input/Output Library #include <cstdlib> //Srand #include <ctime> //Time to set random number seed #include <cmath> //Math Library #include <iomanip> //Format Library using namespace std; //User Libraries //Global Constants, no Global Variables...
**** In java matrix(2 dimensional array) size is fixed. so I have taken the new matrix (data2) in below code snippet. new matrix (data2) dimension is equal to transpose matrix's dimension of data. And I have sent each pixel value to the new matrix(data2). *** Pixel[][] data = theImage.getData(); Pixel[][] data2 = new Pixel[theImage.getWidth()][theImage.getHeight()]; for(int row=theImage.getHeight()-1; row>=0; row--){ for(int col=0; col<theImage.getWidth(); col++){ data2[col][(theImage.getHeight()-1)-row] = data[row][col]; } } theImage.setData(data2);...
Make a program using Java that asks the user to input an integer
"size". That integer makes and prints out an evenly spaced, size by
size 2D array (ex: 7 should make an index of 0-6 for col and rows).
The array must be filled with random positive integers less than
100. Then, using recursion, find a "peak" and print out its number
and location. (A peak is basically a number that is bigger than all
of its "neighbors" (above,...
1.The code box below includes a live 2 dimensional array variable called gridNums. This array holds integers. You cannot see its declaration or initialization. What value is in the zeroth (initial) position of the second row? Print this array entry to the console. (Note: remember that the second row is actually row 1). Enter your code in the box below. 2.The code box below includes a live 3x3 2-dimensional array variable called fredsNums. This array holds integers. You cannot see...
Write a java program that create a 2 dimensional array of type double of size 10 by 10. Fill the array with random numbers using a random number generator. Print the array contents. Write a java program that creates a file called data.txt that uses the PrintWriter class. Write the numbers 1 to 42 into the file. Close the file. Attach both files. Thank you in advance
Hello Guys. I need help with this its in java In this project you will implement a Java program that will print several shapes and patterns according to uses input. This program will allow the use to select the type (say, rectangle, triangle, or diamond), the size and the fill character for a shape. All operations will be performed based on the user input which will respond to a dynamic menu that will be presented. Specifically, the menu will guide...