84 410
Assignments Done
99,1%
Successfully Done
In March 2020

# Answer to Question #53300 in Java | JSP | JSF for sai

Question #53300
1.Write a code fragment that prints the contents of a two-dimensional boolean array, using * to represent true and a space to represent false. Include row and column numbers.package homework; 2.What values does the following code put in the array a [] ? int N = 10; int[] a = new int[N]; a[0] = 1; a[l] = 1; for (int i = 2; i < N; i++) a[i] = a[i-l] + a[i-2]; 3.Write a static method max3 () that takes three int values as arguments and returns the value of the largest one.Add an overloaded function that does the same thing with three double values.
1
2015-07-10T02:27:44-0400

2. It is Fibonacci number.
The first two numbers in the Fibonacci sequence are either 1 and 1 and each subsequent number is the sum of the previous two.
package array;

import java.util.Random;

public class Demo {
final static Random random = new Random();

static boolean[][] array = new boolean[100][100];

static void showArray(boolean[][] array) {
System.out.println("Start");
for(int i = 0; i < 100; i++) {
for(int j = 0; j < 100; j++) {
if(array[i][j])
System.out.println("*");
else
System.out.println(" ");
}
System.out.println("End.");
}
}

static void fibonacciNumber() {
int N = 10;
int[] a = new int[N];
a[0] = 1;
a[1] = 1;
for (int i = 2; i < N; i++)
a[i] = a[i-1] + a[i-2];

System.out.print("Fibonacci Numbers ");
for(int i = 0; i < N; i++) {
System.out.print(a[i] + " ");
}
System.out.println("");

}

public static int max3(int x, int y, int z) {
int temp;
if(x > y)
{
temp = x;
}
else {
temp = y;
}

if(temp > z) {
return temp;
}
else {
return z;
}
}

public static double max3(double x, double y, double z) {
double temp;
if(x > y)
{
temp = x;
}
else {
temp = y;
}

if(temp > z) {
return temp;
}
else {
return z;
}
}

public static void main(String[] args) {

for(int i = 0; i < 100; i++) {
for(int j = 0; j < 100; j++) {
array[i][j] = random.nextBoolean();
}
}

showArray(array);

fibonacciNumber();

System.out.println("Max int - " + max3(3, 2, 1) );

System.out.println("Max double - " + max3(3.3, 2.2, 1.1) );
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!