You are on page 1of 1

package sean;

import java.util.Scanner;
public class MPLegaspiS {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String email, newStr;
int len, idx;

System.out.print("Enter an email: ");


email = input.nextLine();

len = email.length();
System.out.println("The length of the string is: " + len);

idx = email.indexOf("@");
if (idx > -1) {
if (email.endsWith(".com")) {
newStr = email.substring(idx + 1);
System.out.println(newStr + " is a domain name\n");
} else {
idx = email.lastIndexOf(".");
newStr = email.substring(0, idx);
newStr = newStr.concat(".com is the new email\n");
System.out.println(newStr);
}
}

System.out.print("Enter an index to select a letter: ");


int index = input.nextInt();
char ch = email.charAt(index);

System.out.println("Selected letter: \'" + ch + "\'\n");

switch (ch) {
case 'a' + 'A':
System.out.println(ch + " is a vowel");
break;
case 'e' + 'E':
System.out.println(ch + " is a vowel");
break;
case 'i' + 'I':
System.out.println(ch + " is a vowel");
break;
case 'o' + 'O':
System.out.println(ch + " is a vowel");
break;
case 'u' + 'U':
System.out.println(ch + " is a vowel");
break;
default:
if (ch == '@' || ch == '.' || ch == '!') {
System.out.println(ch + " is a special character");
} else
System.out.println(ch + " is a consonant");
}
}
}

You might also like