Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. //// input String S, output the length of String S
  2. // String s = sc.nextLine();
  3. // System.out.println(s.length());
  4. //// input String A. output YES if A equals to "Happy"
  5. // String a = sc.nextLine();
  6. // if(a.equals("Happy")){System.out.println("yes");}
  7. //// input String B, output the amount of letter "A" inside String B using for loop
  8. // int e = 0;
  9. // String f = sc.nextLine();
  10. // for(int i=0; i<f.length(); i++){
  11. // if(f.equals("A")){e++;}
  12. // }System.out.println(e);
  13. //// input String C, output the amount of "7" inside String C using replace
  14. // String C = sc.nextLine();
  15. // String c2 = C.replaceAll("7", "");
  16. // System.out.println(C.length()-c2.length());
  17. //
  18. //// Using for loop to output "===" 100 times
  19. // for(int i=0; i<100; i++){
  20. // System.out.println("===");
  21. // }
  22. //// Using for loop to output "++" 5 times
  23. // for(int i=0; i<5; i++){
  24. // System.out.println("++");
  25. // }
  26. //// Using for loop to output "HI" 11 times
  27. // for(int i=0; i<11; i++){
  28. // System.out.println("HI");
  29. // }
  30. //// Using for loop to output "Yummy" 10 times
  31. // for(int i=0; i<10; i++){
  32. // System.out.println("Yummy");
  33. // }
  34. //// Using for loop to output "Bruce" 23 times
  35. // for(int i=0; i<23; i++){
  36. // System.out.println("Bruce");
  37. // }
  38. //// Using for loop to output 0 5 10 15 20 25 30
  39. // for(int i=0; i<35; i+=5){
  40. // System.out.println(i);
  41. // }
  42. //// Using for loop to output 1 2 3 4 5
  43. // for(int i=1; i<6; i++){
  44. // System.out.println(i);
  45. // }
  46. // input String S
  47. // Using for loop to output char one by one from String S forward
  48. // Using for loop to output char one by one backward
  49. String w = sc.nextLine();
  50. for(int i=0; i<w.length(); i++){
  51. System.out.print(w.charAt(i));
  52. }System.out.println();
  53. for(int i=w.length()-1; i>=0; i--){
  54. System.out.print(w.charAt(i));
  55. }
  56. // A is 1 3 5 7
  57. // B is 2 4 6 8
  58. // Using nested for loop to output A and B's combination
  59. int[] AA = {1, 3, 5, 7};
  60. int[] Ab = {2, 4, 6, 8};
  61. for(int i=0; i<16; i++){
  62. System.out.println(AA[i]+" "+Ab[i]);
  63. }
  64.  
  65.  
  66.  
  67. }
  68.  
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement