Write a Java program that reads in lines of text from a file then prints out the text with different transformations around the vertical, horizontal, and diagonal axis. The program will accomplish this by reading in the text as a rectangular block of data into a 2D array of characters (char[][]). The program will create only one 2D array and will not copy from one array to another. The dimensions of the 2D array will be contained in the first line of the input file, row first and then columns.
This is whats contained in the file:
4 4
JAVA
PROG
NUMB
FOUR
Apparently, the first 2 integer are there to tell us the row and columns according to our professor. so all we need to transform is the four words below that. And i have trouble reading Characters into the 2D array and tranform them around the vertical horizontal and diagonal axis.
The output supposed to be like this:
AVAJ
GORP
BMUN
RUOF
FOUR
NUMB
PROG
JAVA
RBGA
UMOV
OURA
FNPJ
I know how to code & get the o/p of first two o/p scenarios .. but 3rd one i have no clue and finally how to store the entire results back ..
cheers ty

VulpesPosted Oct 27, 2013, 12:01 PM
SUNIL GUTTAPosted Oct 27, 2013, 7:14 AM
Ty for such quick response
cheers
Ty
John McFlurfinPosted Oct 26, 2013, 11:36 PM
The first line is the last char of each word and then so on. So you would do something like
void method()
{
string java = "JAVA";
string four = "FOUR";
string prog = "PROG";
string numb = "NUMB";
System.out.println(four.charAt(3) + numb.charAt(3) + prog.charAt(3) + java.charAt(3));
System.out.println(four.charAt(2) + numb.charAt(2) + prog.charAt(3) + java.charAt(2));
System.out.println(four.charAt(1) + numb.charAt(1) + prog.charAt(3) + java.charAt(1));
System.out.println(four.charAt(0) + numb.charAt(0) + prog.charAt(3) + java.charAt(0));
}