import java.util.Scanner; public class AsteriskSenior { public static void main(String[] args) { Scanner input = new Scanner(System.in); String inputLine = input.nextLine(); String shapeType; int firstNumber; int secondNumber; int thirdNumber; int fourthNumber; shapeType = obtainLetter(inputLine); if (shapeType.equals("S")) //square { firstNumber = obtainFirstNumber(inputLine); secondNumber = obtainSecondNumber(inputLine); thirdNumber = obtainThirdNumber(inputLine); square(firstNumber, secondNumber, thirdNumber); } else if (shapeType.equals("H")) //up side down triangle { firstNumber = obtainFirstNumber(inputLine); secondNumber = obtainSecondNumber(inputLine); thirdNumber = obtainThirdNumber(inputLine); UDTriangle(firstNumber, secondNumber, thirdNumber); } else if (shapeType.equals("L")) //right side up triangle { firstNumber = obtainFirstNumber(inputLine); secondNumber = obtainSecondNumber(inputLine); thirdNumber = obtainThirdNumber(inputLine); RUTriangle(firstNumber, secondNumber, thirdNumber); } else if (shapeType.equals("B")) //box { firstNumber = obtainFirstNumber(inputLine); secondNumber = obtainSecondNumber(inputLine); thirdNumber = obtainThirdNumberOfBox(inputLine); fourthNumber = obtainFourthNumber(inputLine); box(firstNumber, secondNumber, thirdNumber, fourthNumber); } else if (shapeType.equals("T")) //tic-tac-toe grid { firstNumber = obtainFirstNumber(inputLine); secondNumber = obtainSecondNumber(inputLine); thirdNumber = obtainThirdNumber(inputLine); TTT(firstNumber, secondNumber, thirdNumber); } } public static void square(int firstNumber, int secondNumber, int thirdNumber)//S { for (int a=0; a<(firstNumber*(thirdNumber)-thirdNumber+1); a++) { for (int b=0; b<(firstNumber*(secondNumber)-secondNumber+1);b++) { System.out.print("*"); } System.out.println(""); } } public static void UDTriangle(int firstNumber, int secondNumber, int thirdNumber)//H { for (int i=0; i<firstNumber; i++) { for (int j=0; j<i; j++) { System.out.print(" "); } for (int j=i; j<(firstNumber*(secondNumber)-secondNumber+1); j++) { System.out.print("*"); } System.out.println(""); } } public static void RUTriangle(int firstNumber, int secondNumber, int thirdNumber)//L { } public static void box(int firstNumber, int secondNumber, int thirdNumber, int fourthNumber)//B { } public static void TTT(int firstNumber, int secondNumber, int thirdNumber)//T { } public static String obtainLetter(String inputLine) { //Assume input.nextLine() was used to obtain input int locationOfComma = inputLine.indexOf(","); String theLetter = inputLine.substring(0, locationOfComma); return theLetter; } public static int obtainFirstNumber(String inputLine) { //Assume input.nextInt() was used to obtain input int locationOfFirstComma = inputLine.indexOf(","); //Start of First Way (using 2 parameters .indexOf()) int locationOfSecondComma = inputLine.indexOf(",", locationOfFirstComma+1); String firstNumberString = inputLine.substring(locationOfFirstComma+2, locationOfSecondComma); //Convert from String to int int firstNumber = Integer.valueOf(firstNumberString); return firstNumber; } public static int obtainSecondNumber(String inputLine) { //Assume input.nextInt() was used to obtain input int locationOfFirstComma = inputLine.indexOf(","); //using 2 parameters for .indexOf()) int locationOfSecondComma = inputLine.indexOf(",", locationOfFirstComma+1); int locationOfThirdComma = inputLine.indexOf(",", locationOfSecondComma+1); String secondNumberString = inputLine.substring(locationOfSecondComma+2, locationOfThirdComma); //convert from String to int int secondNumber = Integer.valueOf(secondNumberString); return secondNumber; } public static int obtainThirdNumber(String inputLine) { //Assume input.nextInt() was used to obtain input int locationOfFirstComma = inputLine.indexOf(","); //using 2 parameters for .indexOf()) int locationOfSecondComma = inputLine.indexOf(",", locationOfFirstComma+1); int locationOfThirdComma = inputLine.indexOf(",", locationOfSecondComma+1); //using 1 parameter for .indexOf()) String thirdNumberString = inputLine.substring(locationOfThirdComma+2); //convert from String to int int thirdNumber = Integer.valueOf(thirdNumberString); return thirdNumber; } public static int obtainThirdNumberOfBox(String inputLine) { //Assume input.nextInt() was used to obtain input int locationOfFirstComma = inputLine.indexOf(","); //using 2 parameters for .indexOf()) int locationOfSecondComma = inputLine.indexOf(",", locationOfFirstComma+1); int locationOfThirdComma = inputLine.indexOf(",", locationOfSecondComma+1); int locationOfFourthComma = inputLine.indexOf(",", locationOfThirdComma+1); //convert from String to int String thirdNumberString = inputLine.substring(locationOfThirdComma+2, locationOfFourthComma); int thirdNumber = Integer.valueOf(thirdNumberString); return thirdNumber; } public static int obtainFourthNumber(String inputLine) { //Assume input.nextInt() was used to obtain input int locationOfFirstComma = inputLine.indexOf(","); //using 2 parameters for .indexOf()) int locationOfSecondComma = inputLine.indexOf(",", locationOfFirstComma+1); int locationOfThirdComma = inputLine.indexOf(",", locationOfSecondComma+1); //using 1 parameter for .indexOf()) int locationOfFourthComma = inputLine.indexOf(",", locationOfThirdComma+1); String fourthNumberString = inputLine.substring(locationOfFourthComma+2); //convert from String to int int fourthNumber = Integer.valueOf(fourthNumberString); return fourthNumber; } }