alexman27
Dec 1, 2014, 10:46 PM
Can someone please! Fix this for me?
I need to write a program that reads from a text file of popular girl names and a text file of popular boy names.The user should be able to enter a boy's name, a girl's name, or both, and the application will display messages indicating whether the names were among the most popular.
This is what I have until now.. Thank you for your time : )
import java.io.*;
import java.util.Scanner;
public class NamesSearch {
public static void main(String[] args) throws FileNotFoundException {
File BoysNamesfile = new File ("BoysNames");
Scanner inputFile = new Scanner(BoysNamesfile);
File GirlsNamesfile = new File ("GirlsNames");
Scanner inputFile2 = new Scanner(BoysNamesfile);
String[] BoysNamefile = BoysNamesfile.list();
String[] GirlsNamefile = GirlsNamesfile.list();
Scanner keyboard = new Scanner(System.in);
int choice;
String input = null;
String name;
System.out.println("Enter 1 if you would like to check a boys name in the popular name list, or enter 2 if you would like to+" +
"check for a girls name.");
choice = keyboard.nextInt();
if(choice == 1)
{
System.out.println("Enter the name you would like to check.");
name = keyboard.nextLine();
inputFile = sequentialSearch(BoysNamefile, name);
if (BoysNamesfile.list = name )
{
System.out.println("The name is on the popular list.");
}
else
{
System.out.println("The name is not on the popular list.");
}
}
}
private static Scanner sequentialSearch(String[] boysNamefile, String input) {
// TODO Auto-generated method stub
return null;
}
}
I need to write a program that reads from a text file of popular girl names and a text file of popular boy names.The user should be able to enter a boy's name, a girl's name, or both, and the application will display messages indicating whether the names were among the most popular.
This is what I have until now.. Thank you for your time : )
import java.io.*;
import java.util.Scanner;
public class NamesSearch {
public static void main(String[] args) throws FileNotFoundException {
File BoysNamesfile = new File ("BoysNames");
Scanner inputFile = new Scanner(BoysNamesfile);
File GirlsNamesfile = new File ("GirlsNames");
Scanner inputFile2 = new Scanner(BoysNamesfile);
String[] BoysNamefile = BoysNamesfile.list();
String[] GirlsNamefile = GirlsNamesfile.list();
Scanner keyboard = new Scanner(System.in);
int choice;
String input = null;
String name;
System.out.println("Enter 1 if you would like to check a boys name in the popular name list, or enter 2 if you would like to+" +
"check for a girls name.");
choice = keyboard.nextInt();
if(choice == 1)
{
System.out.println("Enter the name you would like to check.");
name = keyboard.nextLine();
inputFile = sequentialSearch(BoysNamefile, name);
if (BoysNamesfile.list = name )
{
System.out.println("The name is on the popular list.");
}
else
{
System.out.println("The name is not on the popular list.");
}
}
}
private static Scanner sequentialSearch(String[] boysNamefile, String input) {
// TODO Auto-generated method stub
return null;
}
}