Question: Write a program that prompts the user to enter two strings, s1 and s2 , using .nextLine() method and displays the following: 1. largest common
Write a program that prompts the user to enter two strings, s1 and s2, using .nextLine() method and displays the following:
1. largest common prefix of the two strings (case sensitive); 2. number of vowels (A/a, E/e, I/i, O/o, and U/u) in s1; 3. number of consonants in s2; 4. characters of s1 at odd positions; 5. reverse of s2.
If any of s1 or s2 is zero then use System.exit(1); to terminate the program. If there is no common prefix, output "N/A" (with quotes).
Here is a sample run:
| Enter the first string: Welcome to C++ Enter the second string: Welcome to programming Output: 1. The common prefix is: Welcome to 2. # of vowels in s1 is: 4 3. # of consonants in s2 is: 13 4. s1 chars at odd positions: Wloet + 5. reverse of s2 is: gnimmargorp ot emocleW
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
