Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch6test;
- import java.util.Scanner;
- public class Ch6Test
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter email: ");
- String email=sc.nextLine();
- System.out.println("Enter password: ");
- String password=sc.nextLine();
- char[] passArray=password.toCharArray();
- String symbols="*@>$";
- char[] symbolArray=symbols.toCharArray();
- //EMAIL VERIFICATION
- boolean emailValid=true;
- String reverse="";
- if(email.indexOf("hwdsb.on.ca")==-1)emailValid=false;
- int atSymbol=email.indexOf('@');
- substring1=email.substr(0,atSymbol);
- if(beforeAtSymbol.length()<3)emailValid=false;
- char[] b4At=substring1.toCharArray();
- for(int c=beforeAtSymbol.length()-1;c>-1;c--)reverse+=b4At[c];
- //PASSWORD VERIFICATION
- boolean passwordValid=false;
- if(!password.length()>=6)passwordValid=false;
- if(!(passArray[0]>=97&&passArray[0]<=122))passwordValid=false;
- if(!(passArray[0]>=65&&passArray[0]<=90))passwordValid=false;
- for(int c=0;c<password.length();c++)if(passArray[c]!=' ')
- {
- passwordValid=false;
- break;
- }
- for(int c=0;c<password.length();c++)if(!(passArray[c]>=48&&passArray[c]<=57))passwordValid=false;
- for(int c=0;c<password.length();c++)for(int x=0;x<4;x++)if(passArray[c]==symbolArray[x])oneSymbol=true;
- if(!(password.contains(beforeAtSymbol)==true)||!(password.contains(reverse)==true))passwordValid=false;
- if(emailValid==true&&passwordValid==true)System.out.println("Email and password accepted.");
- else System.out.println("Email or Password not accepted!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment