Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.*;
- public class Level14 {
- public static void main(String[] args) {
- StringBuilder str = new StringBuilder(args[0]);
- int len = str.length();
- if (len < 4) {
- System.out.println("ERROR! LENGTH OF WORD IS INSUFFICIENT");
- return;
- }
- System.out.println("Your word has " + len + " characters.");
- char c1 = str.charAt(0);
- char c4 = str.charAt(3);
- System.out.println("The first character in your phrase is " + c1 + ".");
- System.out.println("The fourth character in your phrase is " + c4 + ".");
- int index = len - 1;
- System.out.println("The index of the last character is " + index);
- char last = str.charAt(len - 1);
- System.out.println("The last character in your phrase is " + last + ".");
- int i = 0;
- int n = 0;
- while (i < str.length()) {
- char c = str.charAt(i);
- if (c == 't' || c == 'T') {
- n++;
- }
- i++;
- }
- System.out.println("The number of t's or T's (combined) is " + n);
- i = 0;
- n = 0;
- while (i < str.length()) {
- char c = str.charAt(i);
- if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o' || str.charAt(i) == 'u' || str.charAt(i) == 'A' || str.charAt(i) == 'E' || str.charAt(i) == 'I' || str.charAt(i) == 'O' || str.charAt(i) == 'U') {
- n++;
- }
- i++;
- }
- System.out.println("Your word has " + n + " vowels.");
- int d = len - n;
- System.out.println("Your word has " + d + " non-vowels.");
- StringBuilder strn = new StringBuilder(args[0]);
- System.out.println("Your word in reverse order is " + strn.reverse());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement