Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1.  
  2. public class TulosteluaLikeABoss {
  3.  
  4. public static void tulostaTahtia(int maara) {
  5. // 02-24.1
  6. while (maara > 0) {
  7. System.out.print("*");
  8. maara--;
  9. }
  10. System.out.println("");
  11. }
  12.  
  13. public static void tulostaTyhjaa(int maara) {
  14. // 02-24.1
  15. while (maara > 0) {
  16. System.out.print(" ");
  17. maara--;
  18. }
  19. }
  20.  
  21. public static void jouluKuusi(int korkeus) {
  22. // 02-24.3
  23. int i = 1;
  24. while (korkeus > 0) {
  25. tulostaTyhjaa(korkeus - i);
  26. tulostaTahtia(i);
  27. i += 2;
  28. korkeus--;
  29. }
  30. int luku = 2;
  31. i = 3;
  32. while (luku > 0) {
  33. tulostaTyhjaa(korkeus - i);
  34. tulostaTahtia(i);
  35. luku--;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement