Advertisement
Arush22

Untitled

Jan 26th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. 62. Scanner input = new Scanner(System.in);
  2. System.out.println("Type in your email");
  3. String email = input.next();
  4. int length = email.length();
  5. int counter = 0;
  6. int atCounter = 0;
  7. char currentLetter = email.charAt(counter)
  8. while(counter <= length){
  9. if( currentLetter == '@'){
  10. atCounter++;
  11. }
  12. counter++;
  13. currentLetter = email.charAt(counter)
  14. }
  15. if(atCounter == 1){
  16. System.out.println("The email is valid");
  17. }
  18. else{
  19. System.out.println("The email is invalid");
  20. }
  21.  
  22. 63. Scanner input = new Scanner(System.in);
  23. System.out.println("Type in your ID");
  24. String id = input.next();
  25. int length = id.length();
  26. int counter = 0;
  27. int digitCounter = 0;
  28. char currentChar = email.charAt(counter)
  29. while(counter <= length){
  30. if( currentChar == '1'||currentChar == '2'||currentChar == '3'||currentChar == '4'||currentChar == '5'||currentChar =='6'||
  31. currentChar == '7'||currentChar == '8'||currentChar == '9'||currentChar == '0'){
  32. digitCounter++;
  33. }
  34. counter++;
  35. currentLetter = email.charAt(counter)
  36. }
  37. if(digitCounter == 2){
  38. System.out.println("The id is valid");
  39. }
  40. else{
  41. System.out.println("The id is invalid");
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement