Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. package oefening1hfstk8;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class test {
  6.  
  7. public static void main(String[] args) {
  8. // TODO Auto-generated method stub
  9.  
  10. Scanner keyboard = new Scanner(System.in);
  11.  
  12. int punt1x, punt1y, punt2x, punt2y;
  13. System.out.print("Punt 1 x : ");
  14. punt1x = keyboard.nextInt();
  15. System.out.print("Punt 1 y : ");
  16. punt1y = keyboard.nextInt();
  17. System.out.print("Punt 2 x : ");
  18. punt2x = keyboard.nextInt();
  19. System.out.print("Punt 2 y : ");
  20. punt2y = keyboard.nextInt();
  21.  
  22. if (punt1y < punt2y) {
  23. for (int i = 2; i <= punt1y; i++) {
  24. System.out.println();
  25. for (int j = 2; j <= punt1x; j++) {
  26. System.out.print(" ");
  27.  
  28. }
  29.  
  30. }
  31. System.out.print("p");
  32.  
  33. for (int i = 1; i <= punt2y - punt1y; i++) {
  34. System.out.println();
  35. for (int j = 2; j <= punt2x; j++) {
  36. System.out.print(" ");
  37. }
  38. }
  39.  
  40. System.out.print("p2");
  41. } else if (punt2y < punt1y) {
  42.  
  43. for (int i = 2; i <= punt2y; i++) {
  44. System.out.println();
  45. for (int j = 2; j <= punt2x; j++) {
  46. System.out.print(" ");
  47.  
  48. }
  49.  
  50. }
  51. System.out.print("p2");
  52.  
  53. for (int i = 1; i <= punt1y - punt2y; i++) {
  54. System.out.println();
  55. for (int j = 2; j <= punt1x; j++) {
  56. System.out.print(" ");
  57. }
  58. }
  59. System.out.print("p");
  60.  
  61. } else if (punt1x == punt2x && punt1y == punt2y) {
  62. for (int i = 2; i <= punt1y; i++) {
  63. System.out.println();
  64. for (int j = 2; j <= punt1x; j++) {
  65. System.out.print(" ");
  66. }
  67. }
  68. System.out.print("p");
  69. } else if (punt1y == punt2y) {
  70. for (int i = 2; i <= punt1y; i++) {
  71. System.out.println();
  72. for (int j = 2; j <= punt1x; j++) {
  73. System.out.print(" ");
  74. }
  75. }
  76. System.out.print("p");
  77. for (int i = 2; i <= punt2x - punt1x; i++) {
  78. System.out.print(" ");
  79. }
  80. System.out.print("p2");
  81. }
  82. keyboard.close();
  83. }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement