Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package labtask1;
- /**
- * @author ajeel
- */
- import java.util.Scanner;
- public class Q11 {
- public static void main(String[] args) {
- Scanner reader = new Scanner(System.in);
- System.out.println("enter an email address");
- String email = reader.nextLine();
- System.out.println(email(email));
- }
- public static String email(String emailWithAddress) {
- String emailWithoutAddress = "";
- if(emailWithAddress.endsWith("@gmail.com" )||(emailWithAddress.endsWith("@gmail.com" ))){
- //emailWithoutAddress = emailWithAddress.substring(emailWithAddress.length()-10);
- emailWithoutAddress = emailWithAddress.substring(0, emailWithAddress.length()-10);
- }
- else if (emailWithAddress.endsWith("@hotmail.com")){
- emailWithoutAddress = emailWithAddress.substring(0, emailWithAddress.length()-12);
- }
- return emailWithoutAddress;
- }
- }
Add Comment
Please, Sign In to add comment