Skip to content

Instantly share code, notes, and snippets.

@mohkhz2001
Created October 18, 2019 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohkhz2001/97c7ed6ef70e782d4684a0ec933c5e70 to your computer and use it in GitHub Desktop.
Save mohkhz2001/97c7ed6ef70e782d4684a0ec933c5e70 to your computer and use it in GitHub Desktop.
package chapter4;
import javax.swing.JOptionPane;
import javax.swing.JButton;
public class exersice11 {
public static void main(String[] args) {
// TODO Auto-generated method stub
// input email1
String email1=JOptionPane.showInputDialog("plz enter your email addres");
// check email1
// part 1
int check_email1_1=email1.indexOf(".com");
int check_email1_1_2=check_email1_1+1;
if(check_email1_1_2<1) {
int user=JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(null,"wrong EMAIL" ,"WRONG" ,user);
// this part have more work....
String email1_again=JOptionPane.showInputDialog(null, "enter correct email" );
int check_amail1_again=email1_again.indexOf(".com");
/// not ok
}
// part 2
int check_email1_2=email1.indexOf("@");
int check_email1_2_2 = check_email1_2+1;
if (check_email1_2_2<1) {
int user2=JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(null,"wrong EMAIL" ,"WRONG" ,user2);
// this part have more work....
String email1_again2=JOptionPane.showInputDialog(null, "enter correct email" );
int check_email1_again=email1_again2.indexOf("@");
/// not ok
}
///////////////// check over
//input email2
String email2=JOptionPane.showInputDialog("renter your email plz");
// check email 2
int check_email2_1=email2.indexOf("@");
int check_email2_1_2=check_email2_1+1;
if ( check_email2_1_2<1) {
int user3=JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(null, "wrong email", "WRONG EMAIL",user3);
String email_again3=JOptionPane.showInputDialog("enter correct email");
int check_email_again=email_again3.indexOf("@");
/// not ok
}
int check_email2_2=email2.indexOf(".com");
int check_email_2_2_1=check_email2_2+1;
if(check_email_2_2_1<1) {
int user=JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(null, "wrong email","WRONG EMAIL",user);
String user2=JOptionPane.showInputDialog("enter correct email");
int check_email_again=user2.indexOf("@");
// not ok
}
//confrim email
JOptionPane.showConfirmDialog(null, "are you sure it's your real account??");
// equals the email.
boolean ismatch=email2.equals(email1);
// if
if(ismatch==false) {
JOptionPane.showMessageDialog(null, "wrong");
}
if (ismatch==true) {
JOptionPane.showMessageDialog(null, "ok");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment