Question

((Java)) Ask the user for some letters. Display, in alphabetical order, a list of email address d...

((Java)) Ask the user for some letters. Display, in alphabetical order, a list of email address domains from users that have a first name that begins with the inputted letters.

A domain is the characters after the @ symbol.

[email protected]

Standard Input                 Files in the same directory
Hea
  • mock-data.csv
Output
== Domain Lookup ==\n
Enter some letters\n
Here are the domains of the users that begin with Hea\n
free.fr\n
Found 1 domain(s)\n
Standard Input                 Files in the same directory
He
  • mock-data.csv
Output
== Domain Lookup ==\n
Enter some letters\n
Here are the domains of the users that begin with He\n
apple.com\n
artisteer.com\n
cnbc.com\n
free.fr\n
google.it\n
ihg.com\n
indiatimes.com\n
mtv.com\n
myspace.com\n
pbs.org\n
printfriendly.com\n
spiegel.de\n
surveymonkey.com\n
wufoo.com\n
Found 14 domain(s)\n
Standard Input                 Files in the same directory
X
  • mock-data.csv
Output
== Domain Lookup ==\n
Enter some letters\n
Here are the domains of the users that begin with X\n
tumblr.com\n
Found 1 domain(s)\n
Standard Input                 Files in the same directory
Fer
  • mock-data.csv
Output
== Domain Lookup ==\n
Enter some letters\n
Here are the domains of the users that begin with Fer\n
dailymail.co.uk\n
ebay.co.uk\n
indiegogo.com\n
rediff.com\n
unblog.fr\n
Found 5 domain(s)\n

mock-data.csv

Sheilds,Nisse,[email protected],New York
Lamblin,Codie,[email protected],New Jersey
Bagenal,Emlynne,[email protected],Texas
Krier,Sacha,[email protected],South Carolina
Sammonds,Diana,[email protected],Virginia
Franceschielli,Amara,[email protected],Texas
Coulston,Nicholas,[email protected],Texas
Cadigan,Sampson,[email protected],Georgia
Simanenko,Eleanore,[email protected],North Carolina
Jayes,Brooke,[email protected],California
Beardsdale,Ferdinanda,[email protected],California
Pandie,Melamie,[email protected],Maryland
Dandie,Clement,[email protected],South Carolina
Keenor,Mitchael,[email protected],Oklahoma
Joinsey,Cole,[email protected],Texas
Hanington,Warren,[email protected],Ohio
Bunny,Mose,[email protected],Georgia
Streader,Trumann,[email protected],California
Stenning,Hailee,[email protected],Louisiana
Lillywhite,Case,[email protected],California
Derisley,Ethelind,[email protected],Colorado
Carmichael,Raphaela,[email protected],Kansas
Shurey,Georgie,[email protected],North Carolina
Turpin,Laraine,[email protected],Michigan
Paulus,Tressa,[email protected],New York
Gon,Heidi,[email protected],Connecticut
Lindroos,Melisse,[email protected],Louisiana
Mathy,Glennis,[email protected],Ohio
Doul,Joellyn,[email protected],Texas
Skellern,Hersch,[email protected],New York
Brindley,Griz,[email protected],Virginia
Ghidoli,Georgena,[email protected],North Dakota
Lyddy,Knox,[email protected],New Jersey
Osborne,Fidole,[email protected],Minnesota
Chapelhow,Mick,[email protected],District of Columbia
Pennini,Filip,[email protected],Texas
Lindsey,Abagael,[email protected],Florida
Birrane,Kaye,[email protected],California
Simmens,Anthia,[email protected],Delaware
0 0
Add a comment Improve this question Transcribed image text
Answer #1


Please let me know if you have any doubts or you want me to modify the answer. And if you find this answer useful then don't forget to rate my answer as thumps up. Thank you! :)

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class Driver implements Comparable<PeopleData> {
    private static String first;
    private static String last;
    private static String email;
    private static String state;


    public static ArrayList<String> loadDatabase() {
        File f = new File("/Users/swapnil/IdeaProjects/DisplayNAme/src/mockdata.txt");
        ArrayList<String> result = new ArrayList<>();
        try {
            Scanner inputFile = new Scanner(f);


            while (inputFile.hasNextLine()) {

                String[] temp = inputFile.nextLine().split(",");
                first = temp[0];
                last = temp[1];
                email = temp[2];
                state = temp[3];

                result.add(String.valueOf(new PeopleData(first, last, email, state)));

            }

        } catch (FileNotFoundException e) {
            System.out.println("File is not found!");
        }
        return result;
    }


    public static String searchLetter(String search){
        if (getFirst().contains(search)){

        }
        return email;
    }
    public static String getFirst(){
        return first;
    }

    public static void main(String[] args){
        ArrayList<String> data = new ArrayList<>();
        loadDatabase();
        Scanner keyboard = new Scanner(System.in);

        System.out.println("== Domain Lookup ==");
        System.out.println("Enter some letters");


        System.out.println(data.size());
        System.out.println(data);
        String search = keyboard.nextLine();

        System.out.println(searchLetter(search));


    }

    @Override
    public int compareTo(PeopleData o) {
        return 0;
    }
}

----------------------------------------------------------------------------------------------------------------------------------
public class PeopleData {

    private String first;
    private String last;
    private String email;
    private String state;

    public PeopleData(String first, String last, String email, String state) {
        this.first = first;
        this.last = last;
        this.email = email;
        this.state = state;
    }
}
DisplayNAme /ldeaProjects/DisplayNAme] - .../src/Driver.java [DisplayNAme] ,DisplayNAme-src ƠDriver G Driverjava 렙 mockdata.t

Add a comment
Know the answer?
Add Answer to:
((Java)) Ask the user for some letters. Display, in alphabetical order, a list of email address d...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Form Processing HTML One of the most ubiquitous uses of JavaScript is validating form data on...

    Form Processing HTML One of the most ubiquitous uses of JavaScript is validating form data on the client side before it is submitted to the server. It is done everywhere because it is fast and it gives you a great deal of flexibility in how you handle errors insofar as the GUI is concerned. Attached is an image of some code I wrote (so Blackboard can't mess it up). Some things to notice that will help you with the lab....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT