Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _3_Eclipse {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- int height = scan.nextInt();
- String topBottomAsteriskSeq = newString('*', (2 * height) - 2);
- String topBotomMiddleSpace = newString(' ', height + 1);
- String lensSequence = newString('/', (2 * height) - 2);
- String spacesBetweenFrames = newString(' ', height - 1);
- String bridgeSequence = newString('-', height - 1);
- for (int row = 0; row < height; row++) {
- if (row == 0 || row == height - 1) {
- System.out.printf(" %1$s%2$s%1$s\n", topBottomAsteriskSeq,
- topBotomMiddleSpace);
- } else if (row == (height / 2)) {
- System.out.printf("*%1$s*%2$s*%1$s*\n", lensSequence,
- bridgeSequence);
- } else {
- System.out.printf("*%1$s*%2$s*%1$s*\n", lensSequence,
- spacesBetweenFrames);
- }
- }
- }
- 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