Write a java program that by using 3 output ways (println, print, printf) can pr
ID: 3667140 • Letter: W
Question
Write a java program that by using 3 output ways (println, print, printf) can print out the name ERIK by the following letter format. Those 3 print output ways
should be used at least once for each.
Requirement:
1.Your program must be readable
2.You should compile and run your program in cmd window and on NetBeans
For example:
3.You should snapshot pictures that can show your code, compiling successfully, and
running well.
4.3 comment approaches must be used at least once for each.
5. Show your code is readable and test out the program in both types of environments.
Explanation / Answer
code in Java
/**
*
* @author PINERONE
*/
public class MyName {
//alphabet with data
char alphabet[][][] = {{{' ',' ','A',' ',' '}, {' ','A',' ','A',' '}, {'A',' ',' ',' ','A'}, {'A','A','A','A','A'}, {'A',' ',' ',' ','A'}, {'A',' ',' ',' ','A'}, {'A',' ',' ',' ','A'}},
{{'B','B','B','B',' '}, {'B',' ',' ',' ','B'}, {'B',' ',' ',' ','B'}, {'B','B','B','B',' '}, {'B',' ',' ',' ','B'}, {'B',' ',' ',' ','B'}, {'B','B','B','B',' '}},
{{' ','C','C','C',' '}, {'C',' ',' ',' ','C'}, {'C',' ',' ',' ',' '}, {'C',' ',' ',' ',' '}, {'C',' ',' ',' ',' '}, {'C',' ',' ',' ','C'}, {' ','C','C','C',' '}},
{{'D','D','D','D',' '}, {'D',' ',' ',' ','D'}, {'D',' ',' ',' ','D'}, {'D',' ',' ',' ','D'}, {'D',' ',' ',' ','D'}, {'D',' ',' ',' ','D'}, {'D','D','D','D',' '}},
{{'E','E','E','E','E'}, {'E',' ',' ',' ',' '}, {'E',' ',' ',' ',' '}, {'E','E','E',' ',' '}, {'E',' ',' ',' ',' '}, {'E',' ',' ',' ',' '}, {'E','E','E','E','E'}},
{{'F','F','F','F','F'}, {'F',' ',' ',' ',' '}, {'F',' ',' ',' ',' '}, {'F','F','F',' ',' '}, {'F',' ',' ',' ',' '}, {'F',' ',' ',' ',' '}, {'F',' ',' ',' ',' '}},
{{' ','G','G','G',' '}, {'G',' ',' ',' ','G'}, {'G',' ',' ',' ',' '}, {'G','G','G','G','G'}, {'G',' ',' ',' ','G'}, {'G',' ',' ',' ','G'}, {' ','G','G','G',' '}},
{{'H',' ',' ',' ','H'}, {'H',' ',' ',' ','H'}, {'H',' ',' ',' ','H'}, {'H','H','H','H','H'}, {'H',' ',' ',' ','H'}, {'H',' ',' ',' ','H'}, {'H',' ',' ',' ','H'}},
{{'I','I','I','I','I'}, {' ',' ','I',' ',' '}, {' ',' ','I',' ',' '}, {' ',' ','I',' ',' '}, {' ',' ','I',' ',' '}, {' ',' ','I',' ',' '}, {'I','I','I','I','I'}},
{{'J','J','J','J','J'}, {' ',' ','J',' ',' '}, {' ',' ','J',' ',' '}, {' ',' ','J',' ',' '}, {'J',' ','J',' ',' '}, {'J',' ','J',' ',' '}, {' ','J','J',' ',' '}},
{{'K',' ',' ',' ','K'}, {'K',' ',' ','K',' '}, {'K',' ','K',' ',' '}, {'K','K',' ',' ',' '}, {'K',' ','K',' ',' '}, {'K',' ',' ','K',' '}, {'K',' ',' ',' ','K'}},
{{'L',' ',' ',' ',' '}, {'L',' ',' ',' ',' '}, {'L',' ',' ',' ',' '}, {'L',' ',' ',' ',' '}, {'L',' ',' ',' ',' '}, {'L',' ',' ',' ',' '}, {'L','L','L','L','L'}},
{{'M',' ',' ',' ','M'}, {'M','M',' ','M','M'}, {'M','M',' ','M','M'}, {'M',' ','M',' ','M'}, {'M',' ',' ',' ','M'}, {'M',' ',' ',' ','M'}, {'M',' ',' ',' ','M'}},
{{'N',' ',' ',' ','N'}, {'N','N',' ',' ','N'}, {'N',' ','N',' ','N'}, {'N',' ',' ','N','N'}, {'N',' ',' ',' ','N'}, {'N',' ',' ',' ','N'}, {'N',' ',' ',' ','N'}},
{{' ','O','O','O',' '}, {'O',' ',' ',' ','O'}, {'O',' ',' ',' ','O'}, {'O',' ',' ',' ','O'}, {'O',' ',' ',' ','O'}, {'O',' ',' ',' ','O'}, {' ','O','O','O',' '}},
{{'P','P','P','P',' '}, {'P',' ',' ',' ','P'}, {'P',' ',' ',' ','P'}, {'P','P','P','P',' '}, {'P',' ',' ',' ',' '}, {'P',' ',' ',' ',' '}, {'P',' ',' ',' ',' '}},
{{' ','Q','Q','Q',' '}, {'Q',' ',' ',' ','Q'}, {'Q',' ',' ',' ','Q'}, {'Q',' ',' ',' ','Q'}, {'Q',' ',' ',' ','Q'}, {'Q',' ',' ','Q',' '}, {' ','Q','Q',' ','Q'}},
{{'R','R','R','R',' '}, {'R',' ',' ',' ','R'}, {'R',' ',' ',' ','R'}, {'R','R','R','R',' '}, {'R',' ','R',' ',' '}, {'R',' ',' ','R',' '}, {'R',' ',' ',' ','R'}},
{{' ','S','S','S',' '}, {'S',' ',' ',' ','S'}, {'S',' ',' ',' ',' '}, {' ','S','S','S',' '}, {' ',' ',' ',' ','S'}, {'S',' ',' ',' ','S'}, {' ','S','S','S',' '}},
{{'T','T','T','T','T'}, {' ',' ','T',' ',' '}, {' ',' ','T',' ',' '}, {' ',' ','T',' ',' '}, {' ',' ','T',' ',' '}, {' ',' ','T',' ',' '}, {' ',' ','T',' ',' '}},
{{'U',' ',' ',' ','U'}, {'U',' ',' ',' ','U'}, {'U',' ',' ',' ','U'}, {'U',' ',' ',' ','U'}, {'U',' ',' ',' ','U'}, {'U',' ',' ',' ','U'}, {' ','U','U','U',' '}},
{{'V',' ',' ',' ','V'}, {'V',' ',' ',' ','V'}, {'V',' ',' ',' ','V'}, {'V',' ',' ',' ','V'}, {'V',' ',' ',' ','V'}, {' ','V',' ','V',' '}, {' ',' ','V',' ',' '}},
{{'W',' ',' ',' ','W'}, {'W',' ',' ',' ','W'}, {'W',' ',' ',' ','W'}, {'W',' ','W',' ','W'}, {'W','W',' ','W','W'}, {'W','W',' ','W','W'}, {'W',' ',' ',' ','W'}},
{{'X',' ',' ',' ','X'}, {'X',' ',' ',' ','X'}, {' ','X',' ','X',' '}, {' ',' ','X',' ',' '}, {' ','X',' ','X',' '}, {'X',' ',' ',' ','X'}, {' ','X','X','X',' '}},
{{'Y',' ',' ',' ','Y'}, {' ','Y',' ','Y',' '}, {' ',' ','Y',' ',' '}, {' ',' ','Y',' ',' '}, {' ',' ','Y',' ',' '}, {' ',' ','Y',' ',' '}, {' ',' ','Y',' ',' '}},
{{'Z','Z','Z','Z','Z'}, {' ',' ',' ',' ','Z'}, {' ',' ',' ','Z',' '}, {' ',' ','Z',' ',' '}, {' ','Z',' ',' ',' '}, {'Z',' ',' ',' ',' '}, {'Z','Z','Z','Z','Z'}}};
public void Print(String name){
int c=0;
for (int h=0; h<7; h++){
for (int i=0; i<name.length(); i++){
for (int w=0; w<5; w++){
c= (int)name.charAt(i);
switch (c){
case 0 : System.out.print(" "); break;
case 32 : System.out.print(" "); break;
default : System.out.print(alphabet[c-65][h][w]); break;
}
}
System.out.print(" ");
}
System.out.println();
}
}
public void Printf(String name){
int c=0;
for (int h=0; h<7; h++){
for (int i=0; i<name.length(); i++){
for (int w=0; w<5; w++){
c= (int)name.charAt(i);
switch (c){
case 0 : System.out.printf("%c", ' '); break;
case 32 : System.out.printf("%c", ' '); break;
default : System.out.printf("%c", alphabet[c-65][h][w]); break;
}
}
System.out.printf("%c", ' ');
}
System.out.printf("%c", ' ');
}
}
public static void main(String[] ar){
MyName my = new MyName();
my.Print("NETBEANS");
}
}
i need more time for images :/
the code is completed!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.