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
Translate the following pseudocode for randomly permuting the characters in a string into a C++ program.
Svetllana [295]

Answer:

d

Explanation:

salak sensin kolay gelsin

6 0
3 years ago
Program _______ graphically present the detailed sequence of steps needed to solve a programming problem.
AlekseyPX

Program Pseudocode graphically present the detailed sequence of steps needed to solve a programming problem.

<h3>What are Pseudocode?</h3>

These are known to be a set of codes that a program has graphically depicted all of its sequence of steps that can be sued to handle a programming problem.

Note that Pseudocode is a form of artificial and man made informal language that is often used by programmers to create  algorithms.

Learn more about Program from

brainly.com/question/153827

#SPJ1

3 0
3 years ago
Help pls nnnnnnnnnnnnnnnnnnnn
kiruha [24]

Answer:

3rd choice

Explanation:

i did that yesterday

5 0
3 years ago
Which automated method for VPN connection deployment would work best in combination with Microsoft Intune or Microsoft Endpoint
maks197457 [2]

There are different kinds of automated method for VPN connection deployment. The automated method for VPN connection deployment would work best  is ProfileXML

  • ProfileXML is known to be often used as a delivery methods in Windows PowerShell, Microsoft Endpoint Configuration Manager, and Intune. For an individual to be able to use the ProfileXML VPNv2 CSP setting, one have to construct XML by using the ProfileXML schema.

An individual can configure the Always On VPN client by using the PowerShell, Microsoft Endpoint Configuration Manager, or Intune. They all need an XML VPN profile to configure the appropriate VPN settings.

Learn more from

brainly.com/question/25554117

3 0
3 years ago
If an if-else statement is true, it will include which kinds of results?
WARRIOR [948]
The answer is c because the answer is as you know the if else statement
3 0
3 years ago
Other questions:
  • Hen pointing to a tool on the ribbon, a ______ appears, displaying information about the tool.
    7·1 answer
  • Why should you avoid the use of sarcasm cliches and idioms in busniess letters?
    9·2 answers
  • Suppose that you are given the following partial data segment, which starts at address 0x0700 : .data idArray DWORD 1800, 1719,
    7·1 answer
  • Software that manages the resources of the computer is called:
    12·1 answer
  • What is the problem we can't build shelter on mars ?
    6·1 answer
  • Count characters Write a program whose input is a string which contains a character and a phrase, and whose output indicates the
    6·1 answer
  • What is typescript can you please give me a description of what it is
    13·1 answer
  • I used the Pearson correlation coefficient for my study to test the correlation and how strong is the relationship between two v
    10·2 answers
  • States that processing power for computers would double every two years
    6·1 answer
  • ANSWER QUICKLY!!!
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!