Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is java In this program, you are going to read in a top 50 women in busines

ID: 3587906 • Letter: T

Question

This is java

In this program, you are going to read in a top 50 women in business data set file, Top50.txt. You are going to create a BusinessWoman object which keeps track of the ID, FirstName, LastName, CompanyName, and Age.


You are going to store it into an array of BusinessWoman objects. The default starting size is 10. You are going mimic an ArrayList, and when you add items you will use an add method that you create. If you run out of space, you need to expand the array (double its size) and copy all the previous items into the new array when you run out of space.
Finally, you should print out each of the objects by using a get method that you create. Specifics:

1. Read in the Top50 file and create BusinessWoman objects. 2. Store each object into the array you created. 3. Initialize the array size to 10. Please do not use an actual ArrayList. 4. Create an expand method when the number of items read in exceeds the size of the array. 5. Create a size method to keep track of how large your "ArrayList. " 6. Create an add method to add items to your "ArrayList. " 7. Create a get method to get items out of your "ArrayList.” 8. Print out all the students in your "ArrayList" at the end.

Top50.txt.

ID,FirstName,LastName,Company,Age,
1,Mary,Barra,General Motors,55,
2,Indra,Nooyi,PepsiCo,61,
3,Marillyn,Hewson,Lockheed Martin,63,
4,Abigail,Johnson,Fidelity Investments,55,
5,Sheryl,Sandberg,Facebook,48,
6,Ginni,Rometty,IBM,60,
7,Meg,Whitman,Hewlett Packard Enterprise,61,
8,Safra,Catz,Oracle,55,
9,Phebe,Novakovic,General Dynamics,59,
10,Ruth,Porat,"Google, Alphabet",59,
11,Lynn,Good,Duke Energy,58,
12,Helena,Foulkes,CVS Health,53,
13,Angela,Ahrendts,Apple,57,
14,Susan,Wojcicki,"Google, Alphabet",49,
15,Tricia,Griffith,Progressive,52,
16,Cathy,Engelbert,Deloitte,52,
17,Pam,Nicholson,Enterprise Holdings,57,
18,Ann,Marie Campbell,Home Depot,52,
19,Geisha,Williams,PG&E Corporation,56,
20,Debra,Reed,Sempra Energy,61,
21,Karen,Lynch,Aetna,54,
22,Sandra,Peterson,Johnson & Johnson,58,
23,Heather,Bresch,Mylan,48,
24,Marianne,Lake,JPMorgan Chase,48,
25,Margaret,Keane,Synchrony Financial,58,
26,Amy,Hood,Microsoft,45,
27,Mary,Callahan Erdoes,JPMorgan Chase,50,
28,Judith,McKenna,"Walmart U.S., Walmart",51,
29,Barbara,Rentler,Ross Stores,60,
30,Leanne,Caret,Boeing,50,
31,Denise,Morrison,Campbell Soup,63,
32,Vicki,Hollub,Occidental Petroleum,57,
33,Shari,Ballard,Best Buy,51,
34,Debra,Crew,"Reynolds American, British American Tobacco",46,
35,Kathleen,Murphy,Fidelity Investments,54,
36,Lynne,Doughtie,KPMG U.S.,54,
37,Mary,Mack,Wells Fargo,54,
38,Julie,Sweet,Accenture,49,
39,Carolyn,Tastad,Procter & Gamble,56,
40,Bridget,Van Kralingen,IBM,54,
41,Crystal,Hanlon,Home Depot,52,
42,Shira,Goodman,Staples,56,
43,Jennifer,Taubert,Johnson & Johnson,54,
44,Anna,Manning,Reinsurance Group of America,59,
45,Michele,Buck,Hershey,56,
46,Deanna,Mulligan,Guardian Life Insurance,54,
47,Bonnie,Hammer,Comcast,67,
48,Mary,Dillon,Ulta Beauty,56,
49,Margo,Georgiadis,Mattel,53,
50,Anne,Finucane,Bank of America,65,
51,Reese,Witherspoon,,41,

Explanation / Answer

BusinessWoman.java


public class BusinessWoman {
public BusinessWoman(int id, String firstName, String lastName, String company, int age) {
super();
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
company = company;
this.age = age;
}
private int id;
private String firstName;
private String lastName;
private String company;
private int age;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
company = company;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return id + " " + firstName + " " + lastName + " " + company + " " + age;
}
  
}

BusinessWomenArray.java


public class BusinessWomenArray {
private BusinessWoman[] arr;
int size = 0;
public BusinessWomenArray() {
arr = new BusinessWoman[10];
}
  
public void add(BusinessWoman b) {
arr[size++] = b;
if (size == arr.length) {
expand();
}
}
  
public BusinessWoman get(int i) {
return arr[i];
}
  
private void expand() {
BusinessWoman[] tempArr = new BusinessWoman[arr.length*2];
for (int i = 0; i < size; i++) {
tempArr[i] = arr[i];
}
arr = tempArr;
}
  
public int size() {
return size;
}

}

BusinessWomenReader.java // main class

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


public class BusinessWomenReader {
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(new File("Top50.txt"));
BusinessWomenArray barr = new BusinessWomenArray();
if (sc.hasNextLine()) sc.nextLine();
while(sc.hasNextLine()) {
String line = sc.nextLine();
String details[] = line.split(",");
int id = Integer.parseInt(details[0]);
String firstName = details[1];
String lastName = details[2];
String company = details[3];
for (int i = 4; i < details.length-1; i++) {
company += ", " + details[i];
}
int age = Integer.parseInt(details[details.length-1]);
BusinessWoman bw = new BusinessWoman(id, firstName, lastName, company, age);
barr.add(bw);
}
for (int i = 0; i < barr.size(); i++) {
System.out.println(barr.get(i));
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote