· 8 years ago · Apr 10, 2018, 12:20 PM
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package javaapplication16;
7
8import java.util.Scanner;
9
10/**
11 *
12 * @author SHarris13
13 */
14public class JavaApplication16 {
15
16 /**
17 * @param args the command line arguments
18 */
19 public static void main(String[] args) {
20 Scanner input = new Scanner(System.in); //Scanner for input
21 int choice = 0; //Names what the starting choice is
22 int emaillength; //Variable for the length of the email
23 String email; //Variable which allows the user to input an email
24 boolean startsnum;
25 String firstname;
26 String surname;
27 String number;
28 String emailend = "";
29 int emailchoice;
30 while(choice != 3) { //Start of while loop
31 System.out.println("Please type the option below..."); //output so people know what to do
32 System.out.println("1) Check if your email is valid..."); //Displays choice 1
33 System.out.println("2) Generate a custom email..."); //Displays choice 2
34 System.out.println("3) Quit..."); //Displays choice 3
35 choice = input.nextInt(); //Allows people to choose their number
36 //Choice one) Check if your email is valid
37 if(choice == 1){ //Activates if the user chooses option one
38 System.out.println("Please enter your email below..."); //Tells the user what to do
39 email = input.next(); //Allows the user to input an email
40 emaillength = email.length(); //Finds the length of the email
41 System.out.println("Your email is "+emaillength+" letters long..."); //Prints the length of the users email
42 if(emaillength < 6) { //If statement that activates when the email is bigger than six characters
43 System.out.println("Your email is too short, I recommend using the generate email tool..." //Prints the message if the if statement is true
44 + " ");
45 }
46 else if(emaillength > 20) { //If else statement that activates when the email length is over 35
47 System.out.println("Your email is too long, I recommend using the generate email tool..." //What will print if the if else statement is true
48 + " ");
49 }
50 else { //else statement that activates if both if statements are false
51 System.out.println("Your email is valid..."); //Prints if the else statement is active
52 }
53 }
54 if(choice == 2) { //This will activate when two is typed for the choice
55 System.out.println("Please enter your first name"); //This shows what the user should do
56 firstname = input.next(); //This allows the user to type their first name
57 System.out.println("Please enter your surname"); //This shows what the user should do
58 surname = input.next(); //This allows the user to enter their surname
59 System.out.println("Please choose a number between 1 and 1000"); //This shows what the user should do
60 number = input.next(); //This allows the user to enter a number between 1 and 1000
61 System.out.println("Choose a email provider"); //This shows what the user should do
62 System.out.println("1) gmail"); //Choice 1
63 System.out.println("2) outlook"); //Choice 2
64 System.out.println("3) icloud"); //Choice 3
65 System.out.println("4) yahoo"); //Choice 4
66 System.out.println("5) aol"); //Choice 5
67 System.out.println("6) other"); //Choice 6
68 emailchoice = input.nextInt(); //This is so the user can enter their choice
69 if(emailchoice == 1) { //if statement that activates when the choice is 1
70 emailend = "gmail.com"; //What the variable will become when chosen
71 }
72 if(emailchoice == 2) {
73 emailend = "outlook.com";
74 }
75 if(emailchoice == 3) {
76 emailend = "icloud.com";
77 }
78 if(emailchoice == 4) {
79 emailend = "yahoo.com";
80 }
81 if(emailchoice == 5) {
82 emailend = "aol.com";
83 }
84 if(emailchoice == 6) {
85 System.out.println("Please enter the name of your email provider");
86 emailend = input.next();
87 emailend = emailend+".com";
88 }
89 System.out.println("This is the email I have generated for you...");
90 System.out.println(firstname+"."+surname+number+"@"+emailend);
91 }
92
93 }
94 System.out.println("");
95 }
96
97 // TODO code application logic here
98 }