Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //// input String S, output the length of String S
- // String s = sc.nextLine();
- // System.out.println(s.length());
- //// input String A. output YES if A equals to "Happy"
- // String a = sc.nextLine();
- // if(a.equals("Happy")){System.out.println("yes");}
- //// input String B, output the amount of letter "A" inside String B using for loop
- // int e = 0;
- // String f = sc.nextLine();
- // for(int i=0; i<f.length(); i++){
- // if(f.equals("A")){e++;}
- // }System.out.println(e);
- //// input String C, output the amount of "7" inside String C using replace
- // String C = sc.nextLine();
- // String c2 = C.replaceAll("7", "");
- // System.out.println(C.length()-c2.length());
- //
- //// Using for loop to output "===" 100 times
- // for(int i=0; i<100; i++){
- // System.out.println("===");
- // }
- //// Using for loop to output "++" 5 times
- // for(int i=0; i<5; i++){
- // System.out.println("++");
- // }
- //// Using for loop to output "HI" 11 times
- // for(int i=0; i<11; i++){
- // System.out.println("HI");
- // }
- //// Using for loop to output "Yummy" 10 times
- // for(int i=0; i<10; i++){
- // System.out.println("Yummy");
- // }
- //// Using for loop to output "Bruce" 23 times
- // for(int i=0; i<23; i++){
- // System.out.println("Bruce");
- // }
- //// Using for loop to output 0 5 10 15 20 25 30
- // for(int i=0; i<35; i+=5){
- // System.out.println(i);
- // }
- //// Using for loop to output 1 2 3 4 5
- // for(int i=1; i<6; i++){
- // System.out.println(i);
- // }
- // input String S
- // Using for loop to output char one by one from String S forward
- // Using for loop to output char one by one backward
- String w = sc.nextLine();
- for(int i=0; i<w.length(); i++){
- System.out.print(w.charAt(i));
- }System.out.println();
- for(int i=w.length()-1; i>=0; i--){
- System.out.print(w.charAt(i));
- }
- // A is 1 3 5 7
- // B is 2 4 6 8
- // Using nested for loop to output A and B's combination
- int[] AA = {1, 3, 5, 7};
- int[] Ab = {2, 4, 6, 8};
- for(int i=0; i<16; i++){
- System.out.println(AA[i]+" "+Ab[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement