1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Veseljchak [2.6K]
3 years ago
14

Hello I'm new to coding and in my class, we have jumped straight into coding with zero experience and or lessons, this is my fir

st assignment and i am completely lost.
Write a program that reads text from a file. Create a 2-dimensional character array that is
6 * 7. Store the characters read in your array in row major order (fill row 0 first, then row
1, etc.). Fill any unused spaces in the 2-D array with the ‘*’ character. If you have more
characters than space, ignore the excess characters.
Extract the characters from your array in column-major order (pull from column 0 first,
then column 1, etc.). Build a new string as you extract the characters. Display the new
string.
Here is an example for the input string
"It was a bright cold day in April, and the clocks were striking thirteen."
Output string: IatdAat apn bcyrdwro i aililtsgdn,h h e
Computers and Technology
1 answer:
spin [16.1K]3 years ago
6 0

Answer:

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

public class CharTwoDArray {

   public static void main(String[] args) {

       String file = "word.txt";

       final int MAX_CHARS = 1000;

       int count = 0;

       char array[] = new char[MAX_CHARS];

       char array2D[][] = new char[6][7];

       try {

           int t;

           FileReader fr = new FileReader(file);

           BufferedReader br = new BufferedReader(fr);

           while ((t = br.read()) != -1) {

               if ((char) t == '\n') continue;

               array[count++] = (char) t;

           }

       } catch (IOException e) {

           System.out.println("Error in opening file!");

           System.exit(0);

       }

       int t = 0;

       for (int x = 0; x < 6; x++) {

           for (int y = 0; y < 7; y++) {

               // if no char then adding *

               if (t >= count) {

                   array2D[x][y] = '*';

               } else

                   array2D[x][y] = array[t++];

           }

       }

       for (int i = 0; i < 6; i++) {

           for (int j = 0; j < 7; j++) {

               System.out.print(array2D[i][j]);

           }

           System.out.println();

       }

   }

}

Explanation:

  • Use buffer reader for reading file .
  • Add char to 1D array.
  • Add 1D array  to 2D array.
  • Display the 2D array .
You might be interested in
You want to search the web for information on the movie Captain America: Civil War. What would be the best way to enter the key
Digiron [165]

Answer:

Option C i.e., Captain America: Civil War.

Explanation:

When the user required the data or information of the movie Captain America: Civil War then, the following option is the best format to search for the information of the movie because if any user search anything in the proper format then they gets better results related to the following search and if the user enters improperly then they also get the information but it takes some time to satisfy you.

7 0
3 years ago
The danger in using soy solvents is that they: A) Are not approved by the FDA B) Take paint off of surfaces where used C) Are no
tatuchka [14]

Take paint off surfaces

sp2

8 0
3 years ago
Read 2 more answers
Marisa wants to customize her computer's default firmware. ROM allows data to be changed or modified when necessary.
ludmilkaskok [199]

Answer: ROM stands for "Read-only memory", this is permanent, so false.

4 0
2 years ago
Read 2 more answers
The ____ category of apps makes the computer easier for blind people to use.
Schach [20]

The accessibility category of apps makes the computer easier for blind people to use. In general the accessibility apps are apps that help people with disabilities use a particular piece of hardware. For example there is an app designed to help blind people use their devices by paring them with a voluntary non-blind people trough audio-video connections.





4 0
3 years ago
Which top-level domain can be used by anyone, regardless of their affiliation?
Firdavs [7]

Answer:

C. org

Explanation:

org is an open domain so anyone is allowed to register a .org domain

7 0
3 years ago
Other questions:
  • To illustrate a point in a Word document with a simple chart, what command should you select
    6·2 answers
  • When u look at a green object through red glass the object will appear
    11·2 answers
  • Select the correct answer. Ryan received an email from a person claiming that he is an employee of the bank in which Ryan has a
    11·2 answers
  • Suppose your boss has asked you to write a letter to a client about a problem with their order. What format of writing would you
    9·1 answer
  • Is there anyone who is learning coding if so then can you tell me how to be perfect in coding​
    14·1 answer
  • Which of the following regarding the Ames test is true? a. It is used to identify newly formed auxotrophic mutants. b. It is use
    14·1 answer
  • In this lab, your task is to complete the following: Enable all of the necessary ports on each networking device that will allow
    9·1 answer
  • Which name is a default library name in Windows 7?
    14·1 answer
  • Match the title of the work of fiction to the description given.
    8·1 answer
  • :|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!