Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // emailapp.java
- public class EmailApp {
- public static void main(String[] args){
- Email user = new Email();
- user.createEmail();
- }
- }
- // email.java - new file
- import java.util.Random;
- import java.util.Scanner;
- public class Email {
- private String firstName;
- private String lastName;
- private String company;
- private String password;
- private String[] usersFirstName = {"Alex", "Fay", "Elliemae", "Lawrence"};
- private String[] usersLastName = {"OConnor", "Powell", "Hull", "Watson"};
- private int numbers;
- Random rand = new Random();
- Scanner input = new Scanner(System.in);
- public void createEmail(){
- this.firstName = setFirstName().toLowerCase();
- this.lastName = setLastName().toLowerCase();
- this.company = setCompany().toLowerCase();
- this.numbers = setNumbers();
- this.password = setPassword();
- System.out.println("Email Created: " + this.firstName + this.lastName + this.numbers + "@" + this.company + ".com");
- System.out.println("Password: " + this.password);
- }
- private String setPassword(){
- this.password = this.firstName.charAt(0) + this.lastName + this.numbers;
- return this.password;
- }
- private String setFirstName(){
- System.out.println("Enter your first name:");
- this.firstName = input.nextLine();
- return this.firstName;
- }
- private String setLastName(){
- System.out.println("Enter your last name:");
- this.lastName = input.nextLine();
- return this.lastName;
- }
- private int randNum(int min, int max){
- int randNum = rand.nextInt((max - min) + 1) + min;
- return randNum;
- }
- private int setNumbers(){
- this.numbers = randNum(111, 999);
- return this.numbers;
- }
- private String setCompany(){
- System.out.println("Enter the company name:");
- this.company = input.nextLine();
- return this.company;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment