Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 62. Scanner input = new Scanner(System.in);
- System.out.println("Type in your email");
- String email = input.next();
- int length = email.length();
- int counter = 0;
- int atCounter = 0;
- char currentLetter = email.charAt(counter)
- while(counter <= length){
- if( currentLetter == '@'){
- atCounter++;
- }
- counter++;
- currentLetter = email.charAt(counter)
- }
- if(atCounter == 1){
- System.out.println("The email is valid");
- }
- else{
- System.out.println("The email is invalid");
- }
- 63. Scanner input = new Scanner(System.in);
- System.out.println("Type in your ID");
- String id = input.next();
- int length = id.length();
- int counter = 0;
- int digitCounter = 0;
- char currentChar = email.charAt(counter)
- while(counter <= length){
- if( currentChar == '1'||currentChar == '2'||currentChar == '3'||currentChar == '4'||currentChar == '5'||currentChar =='6'||
- currentChar == '7'||currentChar == '8'||currentChar == '9'||currentChar == '0'){
- digitCounter++;
- }
- counter++;
- currentLetter = email.charAt(counter)
- }
- if(digitCounter == 2){
- System.out.println("The id is valid");
- }
- else{
- System.out.println("The id is invalid");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement