sudoaptinstallname

Untitled

Jan 25th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /*
  6. Amon Guinan
  7.  
  8. Friday, January 25.
  9. Program detects whether emails have a single "@" or not.
  10. */
  11. public class exercises {
  12. public static void main(String [] args)
  13. {
  14. String email;
  15.  
  16. System.out.println("Enter a valid email address.");
  17. Scanner input = new Scanner(System.in);
  18. email = input.nextLine();
  19.  
  20. if(email.indexOf("@") == -1)
  21. {
  22. System.out.print("Invalid email address.");
  23. System.exit(255);
  24. }
  25.  
  26. email = email.replaceFirst("@","_");
  27.  
  28. if(email.indexOf("@") != -1){
  29. System.out.print("Invalid email address.");
  30. }
  31. else
  32. {
  33. System.out.print("Valid email address.");
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment