You are on page 1of 7

Create a program that will ask the user to: a.

choose from the following inputs: x, y, z, xy, yz, zx, xyz b. ask for the height of each letter (odd number), starting from number 3

package javaapplication9; import java.io.*; public class Main { public static void main(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("\n\nSubmitted by: MIRALLES, JEFFERSON D. / CSSD01"); System.out.println("\n -----------------------------------------------------\n"); System.out.println("FIRST INPUT"); System.out.print("(Choose from the following inputs: x, y, z, xy, yz, zx, xyz): "); String s=br.readLine(); int l=s.length(); System.out.println("\nSECOND INPUT "); System.out.print("(Choose odd number starting from 3): "); String sistring=br.readLine(); int x=Integer.parseInt(sistring); /*Programmed By: Jefferson D. Miralles */ char[] chars = new char[x]; if (l==1) { if (s.charAt(0)== 'x') { for (int i = 0; i < x; i++) { chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++) { if (j == i || j == (x - 1 - i)) { continue; } chars[j] = ' '; } System.out.println(new String(chars)); } } if (s.charAt(0)== 'y') { int temp=x/2; for (int i = 0; i < x; i++) { chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++)

{ if (j == i || j == (x - 1 - i)) { continue; } chars[j] = ' '; } System.out.println(new String(chars)); if (temp==i) { for (int c=0;c<temp;c++) { chars[temp]='*'; chars[c]=' '; System.out.println(chars); } i=x; } } } if (s.charAt(0)== 'z') { for (int i=0;i<x;i++) { chars[i]='*'; } System.out.println(chars); int temp=x-2; int co=1; for (int i=0;i<temp;i++) { for (int c=0;c<x;c++) { chars[c]=' '; } chars[x-1-co]='*'; co++; System.out.println(chars); } for (int i=0;i<x;i++) { chars[i]='*'; } System.out.println(chars); } } /*Programmed By: Jefferson D. Miralles */ if (l==2) { if (s.charAt(0)== 'x' && s.charAt(1)=='y') { for (int i = 0; i < x; i++)

{ chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++) { if (j == i || j == (x - 1 - i)) { continue; } chars[j] = ' '; } System.out.println(new String(chars)); } System.out.println(""); int temp=x/2; for (int i = 0; i < x; i++) { chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++) { if (j == i || j == (x - 1 - i)) { continue; } chars[j] = ' '; } System.out.println(new String(chars)); if (temp==i) { for (int c=0;c<temp;c++) { chars[temp]='*'; chars[c]=' '; System.out.println(chars); } i=x; } } } if (s.charAt(0)== 'y' && s.charAt(1)=='z') { int temp=x/2; for (int i = 0; i < x; i++) { chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++) { if (j == i || j == (x - 1 - i)) { continue; }

chars[j] = ' '; } System.out.println(new String(chars)); if (temp==i) { for (int c=0;c<temp;c++) { chars[temp]='*'; chars[c]=' '; System.out.println(chars); } i=x; } } /*Programmed By: Jefferson D. Miralles */ for (int i=0;i<x;i++) { chars[i]='*'; } System.out.println(chars); int temp2=x-2; int co=1; for (int i=0;i<temp2;i++) { for (int c=0;c<x;c++) { chars[c]=' '; } chars[x-1-co]='*'; co++; System.out.println(chars); } for (int i=0;i<x;i++) { chars[i]='*'; } System.out.println(chars); } if (s.charAt(0)== 'z' && s.charAt(1)=='x') { for (int i=0;i<x;i++) { chars[i]='*'; } System.out.println(chars); int temp=x-2; int co=1; for (int i=0;i<temp;i++) { for (int c=0;c<x;c++) {

} for (int i=0;i<x;i++) { chars[i]='*'; } System.out.println(chars); for (int i = 0; i < x; i++) { chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++) { if (j == i || j == (x - 1 - i)) { continue; } chars[j] = ' '; } System.out.println(new String(chars)); } } } if (l==3) { if (s.charAt(0)== 'x' && s.charAt(1)=='y' && s.charAt(2)=='z') { for (int i = 0; i < x; i++) { chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++) { if (j == i || j == (x - 1 - i)) { continue; } chars[j] = ' '; } System.out.println(new String(chars)); } System.out.println(""); int temp=x/2; for (int i = 0; i < x; i++) { chars[i] = '*'; chars[x - 1 - i] = '*'; for (int j = 0; j < x; j++) {

chars[c]=' '; } chars[x-1-co]='*'; co++; System.out.println(chars);

if (j == i || j == (x - 1 - i)) { continue; } chars[j] = ' '; } System.out.println(new String(chars)); if (temp==i) { for (int c=0;c<temp;c++) { chars[temp]='*'; chars[c]=' '; System.out.println(chars); } i=x; } } for (int i=0;i<x;i++) { chars[i]='*'; } /*Programmed By: Jefferson D. Miralles */ System.out.println(chars); int temp2=x-2; int co=1; for (int i=0;i<temp2;i++) { for (int c=0;c<x;c++) { chars[c]=' '; } chars[x-1-co]='*'; co++; System.out.println(chars); } for (int i=0;i<x;i++) { chars[i]='*'; } System.out.println(chars); }

You might also like