KillianO92

EmailAndGrade

Dec 16th, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class EmailAndGrade
  6. {
  7.  
  8.     public static void main(String[] args)
  9.     {
  10.         //Variables
  11.         String sEmail, sError, sTest;
  12.         int iTest;
  13.         char cGrade;
  14.  
  15.         sEmail = JOptionPane.showInputDialog("Enter your email: ");
  16.        
  17.        
  18.         private static boolean validEmail(String[] sEmail)
  19.                 {
  20.                 // editing to make requirements listed
  21.                 // return email.matches("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}");
  22.                 return email.matches("[A-Z0-9]{7}+@[springfieldcollege]+\\.[edu]");
  23.         }
  24.        
  25.         sError = "One or More Errors with the Input Email.\n
  26.                 Email is Empty.\n
  27.                 Email must be less than 30 characters.\n
  28.                 Must end in: @springfieldcollege.edu.\n
  29.                 Can only have one @.\n
  30.                 Must start with A through Z or a through z.\n
  31.                 Can not have: # $ % & ,\n";
  32.         sTest = JOptionPane.showInptDialog("Enter Test Grade: ");
  33.        
  34.         iTest = Integer.parseInt(sTest);
  35.  
  36.        
  37.     }
  38.    
  39.     /*
  40.         void checkEmails()
  41.         {
  42.             for(String email : emailAddresses) {
  43.             if(validEmail(email)) {
  44.                  // it's a good email - do something good with it
  45.    
  46.             }
  47.             else {
  48.                  // it's a bad email - do something... bad to it? sounds dirty...
  49.                 JOptionPane.showMessageDialog(null,
  50.                                   sError,
  51.                                   "Email Error - Killian O'Brien",
  52.                                                   JOptionPane.INFORMATION_MESSAGE);
  53.             }
  54.     }*/
  55.  
  56.        
  57.         System.exit{0};
  58. }
Advertisement
Add Comment
Please, Sign In to add comment