Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _3_WineGlass {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- int height = scan.nextInt();
- int asterisks = height - 2;
- String asteriskSeq = newString('*', asterisks);
- System.out.printf("\\%s/\n", asteriskSeq);
- String outerDotSeq;
- for (int row = 1; row < (height / 2); row++) {
- asterisks -= 2;
- outerDotSeq = newString('.', row);
- asteriskSeq = newString('*', asterisks);
- System.out.printf("%1$s\\%2$s/%1$s\n", outerDotSeq, asteriskSeq);
- }
- outerDotSeq = newString('.', (height - 2) / 2);
- for (int row = (height / 2); row < height; row++) {
- if (row == (height - 1) || (height >= 12 && row >= (height - 2))) {
- System.out.println(newString('-', height));
- } else {
- System.out.printf("%1$s||%1$s\n", outerDotSeq);
- }
- }
- }
- private static String newString(char ch, int size) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < size; i++) {
- sb.append(ch);
- }
- return sb.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement