SquareStar.java 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. /**
  6. *
  7. * @author LH
  8. */
  9. public class SquareStar
  10. {
  11. public static void main(String[] args) throws Exception
  12. {
  13. int m = InteractiveIO.promptForInt("Zahl bitte");
  14. int n = InteractiveIO.promptForInt("Zahl bitte");
  15. int bsize = m/2-n;
  16. InteractiveIO.write(""+bsize);
  17. String fullstarline = "";
  18. String holeLine = "";
  19. for (int i = 0; i < m; i++)
  20. {
  21. fullstarline+="*";
  22. if(i>=bsize&&(i<m-bsize))
  23. {
  24. holeLine+=" ";
  25. }
  26. else
  27. {
  28. holeLine+="*";
  29. }
  30. }
  31. for (int i = 0; i < m; i++)
  32. {
  33. if(i>=bsize&&(i<m-bsize))
  34. {
  35. InteractiveIO.write(holeLine);
  36. }
  37. else
  38. {
  39. InteractiveIO.write(fullstarline);
  40. }
  41. }
  42. }
  43. }