Given the text file “Alamo defenders.txt” (attached to this assignment), write a simple Java program to do the following:
- count how many names are in the file
- find the longest full name in the file
- find the longest single name (first, middle or last) in the file
- find whether there were any Alamo defenders named “Jones”
- write out, to the screen (console), all of the above information
Alamo defenders.txt file:
Juan Abamillo James L. Allen Robert Allen Horace Alsbury George Andrews Miles DeForest Andross Simon Arreola Micajah Autry Jesse B. Badgett Juan A. Badillo Peter James Bailey III Isaac G. Baker William Charles M. Baker John Ballard John J. Ballentine Richard W. Ballentine Andrew Barcena John J. Baugh Samuel G. Bastain Joseph Bayliss John Walker Baylor Jr. Anselmo Bergara John Blair Samuel Blair William Blazeby James Bonham Daniel Bourne James Bowie J. B. Bowman Robert Brown James Buchanan Samuel E. Burns George D. Butler John Cain Robert Campbell William R. Carey Cesario Carmona M.B. Clark Daniel W. Cloud Robert E. Cochran George Washington Cottle Henry Courtman Lemuel Crawford David Crockett Robert Crossman Antonio Cruz y Arocha David P. Cummings Robert Cunningham Matias Curvier Jacob C. Darst John Davis Freeman H.K. Day Squire Daymon William Dearduff Alexandro De la Garza N. Debichi Stephen Dennison Francis L. DeSauque John Desauque Charles Despallier Lewis Dewall Almaron Dickinson James Dickson John Henry Dillard Philip Dimmitt James R. Dimpkins Andrew Duvalt Samuel M. Edwards Conrad Eigenauer J.D. Elliott Frederick E. Elm Lucio Enriques Carlos Espalier Robert Evans Samuel B. Evans James L. Ewing William Keener Fauntleroy William Fishbaugh John Flanders Manuel N. Flores Salvador Flores Dolphin Ward Floyd John Hubbard Forsyth Antonio Fuentes Galba Fuqua William Garnett James W. Garrand James Girard Garrett John E. Garvin John E. Gaston James George William George James Gibson John C. Goodrich Francis H. Gray W.T. Green Albert Calvin Grimes Ignacio Gurrea Brigido Guerrero James C. Gwin John Harris Andrew Jackson Harrison I.L.K. Harrison William B. Harrison Joseph M. Hawkins John M. Hays Charles M. Heiskell Patrick Henry Herndon Pedro Herrera William Daniel Hersee Benjamin Franklin Highsmith Tapley Holland James Holloway Samuel Holloway William D. Howell William Hunter Thomas P. Hutchinson William A. Irwin Thomas R. Jackson William Daniel Jackson Green B. Jameson Gordon C. Jennings Damacio Jiminez John Johnson Lewis Johnson William Johnson William P. Johnson Gregorio Esparza Jos Maria Arocha Jos John Jones James Kenny Andrew Kent Joseph Kent Joseph Kerr George C. Kimble John C. Kin William Philip King William Irvine Lewis William J. Lightfoot Jonathan Lindley William Linn Byrd Lockhart Toribio Losoya George Washington Main William T. Malone William Marshall Albert Martin Samuel Augustus Maverick Edward McCafferty Ross McClelland Daniel McCoy Jr. Jesse McCoy Prospect McCoy William McDowell James McGee John McGregor Robert McKinney S.W. McNeilly Eliel Melton Antonio Menchaca Thomas R. Miller William Mills Isaac Millsaps Edward F. Mitchasson Edwin T. Mitchell Napoleon B. Mitchell Robert B. Moore Willis A. Moore John Morman William Morrison Robert Musselman James Nash AndrT Nava Gerald Navan George Neggan Andrew M. Nelson Edward Nelson George Nelson Benjamin F. Nobles James Northcross James Nowlan L.R. O'Neil George Olamio William Sanders Oury Jose Sebastian Luciano Pacheco George Pagan Christopher Adams Parker William Parks William Patton Richardson Perry Adolf Petrasweiz Amos Pollard Eduardo Ramirez John Purdy Reynolds Thomas H. Roberts James Waters Robertson Ambrosio Rodriguez Guadalupe Rodriquez James M. Rose Jacob Roth Jackson J. Rusk Joseph Rutherford Isaac Ryan W.H. Sanders Mial Scurlock Juan Seguin Marcus L. Sewell Manson Shied Silvero Cleveland Kinloch Simmons Andrew H. Smith Charles S. Smith John William Smith Joshua G. Smith William H. Smith Launcelot Smither Andrew Jackson Sowell John Spratt Richard Starr James E. Stewart Richard L. Stockton A. Spain Summerlin William E. Summers John Sutherland William DePriest Sutherland Edward Taylor George Taylor James Taylor William Taylor B. Archer M. Thomas Henry Thomas Thompson John W. Thomson John M. Thurston Burke Trammel Joe Travis William B. Travis George W. Tumlinson James Tylee Asa Walker Jacob Walker William B. Ward Henry Warnell Joseph G. Washington Thomas Waters William Wells Isaac White Robert White Hiram James Williamson William Wills David L. Wilson John Wilson Anthony Wolf Claiborne Wright Charles Zanco Vicente Zepeda
here's the java code (comments added for explanation) -
package javaapplication3;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class JavaApplication3 { //change the class name to your default
main class (name of java file)
public static void main(String args[] ) throws Exception {
Scanner s = new Scanner(System.in); //scanner Class for taking STD
inputs and outputs
BufferedReader reader; //buffered reader is easy to use for reading
files line by line
reader = new BufferedReader(new
FileReader("C:\Users\*****\Documents\NetBeansProjects\JavaApplication3\src\javaapplication3\Alabama
defenders.txt")); // enter your file location
ArrayList <String> names = new ArrayList<String>();
//An array list to store all names
String line = reader.readLine();
while (line != null) {
names.add(line);
line = reader.readLine(); //reading file line by line
}
int numberOfNames = names.size();
System.out.println("Number of names = " + numberOfNames);
String longestFullName = ""; //to store longest full name
String longestSingeName = ""; //to store longest Single name
int jones=0; //to keep count of number of occurences of name
Jones
for(String name:names){ //You can also use for(int
i=0;i<names.size();i++) and names[i] if you don't know about
these kind of iterations
if(name.length() > longestFullName.length()){ //to check current
name's length is greater than previously largest name
longestFullName = name;
}
String[] nameSplit = name.split(" "); // to split whole name into
single names i.e. first,middle and last names ( Splitted the whole
string by <space> by using (" ") )
for(String singleNames:nameSplit){
if(singleNames.length() > longestSingeName.length()){
longestSingeName = singleNames;
if(singleNames.equals("Jones")){
jones++; //count number of occurences name Jones have
appeared
}
}
}
}
System.out.println("Longest Full Name is : " +
longestFullName);
System.out.println("Longest Single Name is : " +
longestSingeName);
if(jones>0){
System.out.println("There were "+jones+" Jones in Alamo
Defenders");
}
else{
System.out.println("There were no Jones in Alamo Defenders");
}
reader.close();
}
}
Screenshot of output -
Given the text file “Alamo defenders.txt” (attached to this assignment), write a simple Java program to...
in python please PROBLEM : (15 POINTS Use the file 'presidents age, txt You can download this file from D2L (Content' tab) to your lo computer This file contains the age (at the time of their inaguration) of the first 45 presidents (including repeats). Each president's name is separated from his age by a comma Write a function called getAges (). Inside this function, create a dictionary in which every key is the name, and the value is the president's...
Can you solve this in python. Thank you n Exercises 11 through 14, use the file Justices.txt that contains data abou Supreme Court justices, past and present as of Janua 015. Each record of the file the state from which thy ry 2 contains six fields -first name, last name, appointing president, the state from which the were appointed, year appointed, and the year the justice left the court. (For current justices the last field is set to 0.) The...
This project evaluates your understanding of the unique inheritance of X-DNA. Five generations of MaryEllen Sullivan’s family tree are provided in the pedigree chart. MaryEllen decides to take a DNA test that examines her X-DNA. When she gets the results, she discovers that she shares a large piece of X-DNA with a person named Georgia Thomas. When MaryEllen and Georgia compare their family trees, the only overlap they identify is the surname “BENTLEY.” MaryEllen has a Corrine Bentley in her...
Here is my assignment: --------------------------------------------------- Consider the following client class: import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; public class PresidentsMain { public static void main(String[] args) { Map<String, String> PresidentsOfTheUnitedStates = new HashMap<String, String>(); PresidentsOfTheUnitedStates.put("George Washington", "Unaffiliated"); PresidentsOfTheUnitedStates.put("John Adams", "Federalist"); PresidentsOfTheUnitedStates.put("Thomas Jefferson", "Democratic-Republican"); PresidentsOfTheUnitedStates.put("James Madison", "Democratic-Republican"); PresidentsOfTheUnitedStates.put("James Monroe", "Democratic-Republican"); PresidentsOfTheUnitedStates.put("John Quincy Adams", "Democratic-Republican"); PresidentsOfTheUnitedStates.put("Andrew Jackson", "Democratic"); PresidentsOfTheUnitedStates.put("Martin Van Buren", "Democratic"); PresidentsOfTheUnitedStates.put("William Henry Harrison", "Whig"); PresidentsOfTheUnitedStates.put("John Tyler", "Whig"); } } } Extend given client class: Implement a static...
Write a program that reads in BabyNames.txt and produces two files, boynames.txt and girlnames.txt, separating the data for the boys and the girls, and listing them in alphabetical order. This is the code I have, Its not sorting the boys/girls names in seperate files. It is creatinf two files, but has all the names. I also need to alphabetize the names. with an Array. sort import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class BabyNames{ public static void main(String[]...
CREATE TWO C++ PROGRAMS : Program 1 Write a program that reads in babynames.txt (provided) and outputs the top 20 names, regardless of gender. The file has the following syntax: RANK# BoyName Boy#OfBirths Boy% GirlName Girl#OfBirths Girl% You should ignore the rank and percentages. Compare the number of births to rerank. Output should go to standard out. Program 2 Write a program that reads a text file containing floating-point numbers. Allow the user to specify the source file name on...
Write a python code using pandas for this following problem and do not forgot to add comments in your code. Suppose you have a text file called “President.txt” (which is shown below), you have to import this text file in code and using the data of this file, you have to create a new file called “NewPreFile.txt” where you will only show the only selected data of old “president.txt” file. In “NewPreFile.txt” file you need to show the presidents name,...
//*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/ Public abstract class Employee { protected final String name; protected final int id; public Employee(String empName, int empId) { name = empName; id = empId; } public Employee() { name = generatedNames[lastGeneratedId]; id = lastGeneratedId++; } public String getName() { return name; } public int getId() { return id; } //returns true if work was successful. otherwise returns false (crisis) public abstract boolean work(); public String toString() { return...
C++ Create an application that searches a file of male and female first names. A link to the file is provided on the class webpage. "FirstNames2015.txt" is a list of the most popular baby names in the United States and was provided by the Social Security Administration. Each line in the file contains a boy's name and a girl's name. The file is space-delimited, meaning that the space character is used to separate the boy name from the girl name....
Create three or more MySQL Data Control language (DCL) Statements using the Youth League Database. 1. A Create new user statement for the database 2. A statement that grants privileges to the new user 3. A statement that revokes privileges 1. A SQL Text File containing the SQL commands to create the database, create the table, and insert the sample test data into the table. 2. A SQL Text File containing the DCL SQL Statements. eted hemas Untitled Limit to...