Problem statement:
Given an input string from the console as follows
Sample I/O:
aaaaa, bbbb, cccc, d , f , g , i
Sample I/O:
aaaaa, bbbb, cccc, d , f , g , i
Sample O/P:
a5, b4, c4,d1, f1, h1, g1, i1
a5, b4, c4,d1, f1, h1, g1, i1
- import java.util.Scanner;
- public class SwitchStatement {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter the pattern.");
- String pattern = sc.nextLine();
- System.out.println(pattern.charAt(0) + "" + pattern.length());
- }
- }