Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. // CS210 Assignment #1
  2. //Adam Szablya
  3.  
  4.  
  5. public class Chapter1Ex11 {
  6.  
  7. public static void triangle()
  8. {
  9. /*
  10. for(int d = 3; d!=0;--d)
  11. {
  12. for(int ds=3; ds>d; ds++)
  13. {
  14. System.out.print(" ");
  15. }}
  16.  
  17. System.out.println("/");
  18. for(int s = 0; s<3;++s)
  19. {
  20. for(int i=0; i<s; i++){
  21. System.out.print(" ");
  22. }
  23. System.out.println("\\ ");
  24. }*/
  25.  
  26. String forward = "/";
  27. String backward = "\\";
  28. String space = " ";
  29. StringBuffer sb = new StringBuffer();
  30.  
  31. for (int i = 0; i < 3; i++) {
  32. for (int j = 3 - i; j > 0; j--) {
  33. sb.append(space);
  34. }
  35. sb.append(forward);
  36. for (int j = 0; j < i * 2; j++) {
  37. sb.append(space);
  38. }
  39. sb.append(backward);
  40. sb.append("\n");
  41. }
  42. System.out.println(sb.toString());
  43. }
  44.  
  45. public static void BodyOne()
  46. {
  47. System.out.println("+------+ +------+");
  48. for(int r =0; r<3;++r){
  49. for(int f=0; f<2;f++)
  50. {
  51. if(r == 1 && f == 0)
  52. {
  53. System.out.println("+------+ +------+");
  54. System.out.println("|United| |United|");
  55. }
  56. if(f== 1 && r == 1)
  57. {
  58. System.out.println("|States| |States|");
  59. System.out.println("+------+ +------+");
  60. }
  61. else
  62. System.out.println("| | | |");
  63. }
  64. }
  65. System.out.println("+------+ +------+");
  66. }
  67. public static void main(String[] args) {
  68. triangle();
  69. BodyOne();
  70. triangle();
  71.  
  72.  
  73. for(int re = 0; re < 1; re++){
  74. System.out.print(" ");
  75. for(int repe = 0;repe<=re; repe++){
  76. triangle();
  77. BodyOne();
  78. triangle();
  79. //System.out.print(" ");
  80. }
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement