Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class OutputArray { // main method creates array named data 100x100 public static void main(String[] args) { Scanner sc = new Scanner

import java.util.Scanner; public class OutputArray { // main method creates array named data 100x100 public static void main(String[] args) { Scanner sc = new Scanner (System.in); String[][] data = new String [100][100]; // takes user input for rows and columns, stores in int variables rows, cols System.out.print("Enter number of rows."); int rows = sc.nextInt(); System.out.print("Enter number of columns."); int cols = sc.nextInt(); // ex. rows is 4 and cols is 2... //fills selected subarray with random letter of alphabet... how to resolve valueOf? System.out.println("Original 2D array:"); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { int index = (int) (Math.random() *26); char letter = (char) ('A' + index); data [i][j] = String.valueOf(letter); System.out.print(data[i][j] + " "); } System.out.println(); } System.out.println("Combinations:"); printCombinations(data, 0, rows, cols, ""); } // calls printCombinations method... passes array, current row start at 0? // rows, cols, current Output??? just a blank space? or... ??? // I don't understand how the section below works... public static void printCombinations(String[][] data, int currRow, int maxRows, int maxCols, String currentOutput) { if (currRow >= maxRows) { System.out.println(currentOutput); return; } for (int i = 0; i < maxCols && i < data[currRow].length; i++) { printCombinations(data, currRow +1, maxRows, maxCols, currentOutput + data[currRow][i] + " "); } } }

When I copy this program, it gives me three errors. Could someone explain how to fix this?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago