Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Lesson 22 Coding Activity 1
- * Write the code to take a String and print it with one letter per line.
- Sample run:
- Enter a string:
- bought
- b
- o
- u
- g
- h
- t
- */
- import java.util.Scanner;
- import java.lang.Math;
- class Lesson_22_Activity_One {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- System.out.println("Enter a string:");
- String x = scan.nextLine();
- System.out.println(x);
- int len = x.length();
- int b = x.length();
- System.out.println(b);
- while (b > 0)
- {
- System.out.println(x.charAt(len-b));
- b--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement