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
Please help ASAP!!! :))
Talja [164]

Answer:

You can upgrade the OS by applying SECURITY patches to the server

Explanation:

I can't think of anything else it could be

3 0
3 years ago
Sequence encryption is a series of encryptions and decryptions between a number of systems, wherein each system in a network dec
valentina_108 [34]

Answer:

The answer is True.

Explanation:

In a Network data transfer, it is essential for the security purpose that data should be in encrypted form which an unreadable form and it will be decrypted when it reaches the destination system.

It is important for the organization to encrypt data to make it safe from hackers and cryptographic technology is used in data Sequence encryption.

There is a key that is used to decrypt data in the network system and encryption and decryption is a sequential process for the data starting from the initial system and ending in the destination system.

3 0
3 years ago
A7DF is the hexadecimal representation for what bit pattern?
kipiarov [429]

Answer:

1010 0111 1101 1111

Explanation:

A = 10 in decimal = 1010 in binary

7 = 7 in decimal = 0111 in binary

D = 13 in decimal = 1101 in binary

F = 15 in decimal = 1111 in binary

Therefore 0xA7DF = 1010 0111 1101 1111 in binary

6 0
3 years ago
(10 LC)
barxatty [35]

Answer:

college A

Explanation:

7 0
3 years ago
Paul listed the websites he searched to find information on a career in biology ​
balandron [24]

Answer:

The frustration-aggression hypothesis

Explanation:

7 0
3 years ago
Other questions:
  • How do you use the Internet? Think about your typical day. When are you using the Internet? For what purposes? What role does it
    11·1 answer
  • . Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you
    15·1 answer
  • Ip addresses and their corresponding domain names are used to identify computers available through the internet.
    15·1 answer
  • By which method is heat transferred through a metal <br> spoon?
    9·2 answers
  • How would a designer interpret the word denier?
    12·2 answers
  • 5. Write a function that takes two lists of integers and returns a list containing tuples with corresponding elements from both
    8·1 answer
  • Provide a class Letter for authoring a simple letter. In the constructor, supply the names of the sender and the recipient: def
    11·1 answer
  • What is the correct sequence in which a computer operates​
    6·1 answer
  • Which of the following factors is least likely to result in delivery delays?
    7·1 answer
  • Identify the two top benefits of using angel investors to start a business.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!