Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tk.evilus;
- import java.util.Scanner;
- public class choinka {
- public static void main(String[] arg) {
- int a, h;
- char star = '*';
- System.out.print("Enter the height of the Christmas tree: ");
- Scanner input = new Scanner(System.in);
- h = input.nextInt();
- input.close();
- for (int i = 0; i <= h; i++) {
- if (i != h) {
- for (a = 0; a < h * 2; a++) {
- if (a < (h - i) || a > (h + i)) {
- System.out.print(" ");
- } else {
- System.out.print(star);
- }
- }
- } else {
- for (a = 0; a<h*2; a++) {
- if (a<h || a>h)
- System.out.print(" ");
- else
- System.out.print("#");
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement