aj98

Untitled

Sep 5th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package labtask1;
  2.  
  3. /**
  4. * @author ajeel
  5. */
  6. import java.util.Scanner;
  7.  
  8. public class Q11 {
  9.  
  10. public static void main(String[] args) {
  11. Scanner reader = new Scanner(System.in);
  12. System.out.println("enter an email address");
  13. String email = reader.nextLine();
  14. System.out.println(email(email));
  15.  
  16.  
  17. }
  18.  
  19. public static String email(String emailWithAddress) {
  20. String emailWithoutAddress = "";
  21. if(emailWithAddress.endsWith("@gmail.com" )||(emailWithAddress.endsWith("@gmail.com" ))){
  22. //emailWithoutAddress = emailWithAddress.substring(emailWithAddress.length()-10);
  23. emailWithoutAddress = emailWithAddress.substring(0, emailWithAddress.length()-10);
  24. }
  25.  
  26. else if (emailWithAddress.endsWith("@hotmail.com")){
  27. emailWithoutAddress = emailWithAddress.substring(0, emailWithAddress.length()-12);
  28.  
  29. }
  30.  
  31. return emailWithoutAddress;
  32.  
  33.  
  34. }
  35. }
Add Comment
Please, Sign In to add comment