Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
899 B
2
Indexable
Never
import java.util.*;

class Main {

  public static void part1(String s){
    for(int i=0; i<s.length(); i++){
      System.out.print(s.charAt(i)+" ");
    }
  }

  public static void part2(String s){
    part1(s);
    System.out.println();
    for(int i=1; i<s.length()-1; i++){
      System.out.println(s.charAt(i));
    }
  }

  public static void part3(String s){
    
    System.out.println("\nExecuting part1:\n");
    part1(s);
    System.out.println("\n\nExecuting part2:\n");
    part2(s);
    System.out.println("\nExecuting part3:\n");
    part2(s);
    for(int i=s.length()-1; i>=0; i--){
      System.out.print(s.charAt(i)+" ");
    }
  }

  public static void main(String[] args) {
    System.out.print("Enter a string: ");
    Scanner sc = new Scanner(System.in);
    String st = sc.nextLine();
    String s = st.toUpperCase();
    part3(s);
  }
}