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

Please help! I need to create a Java class called Headlines, with the following

ID: 3635122 • Letter: P

Question

Please help!

I need to create a Java class called Headlines, with the following elements:

- Three instance variables that are arrays of type String. Each array should hold at least 12 Strings. The three arrays will hold data read from three different files, described below.

- A method that opens three input files (named settings.txt, actions.txt and people.txt – see attachments) and reads their data into the 3 arrays (put actions in the action bag, etc.)

- A method that generates and prints out “headlines” consisting of strings pulled randomly from each of the bags, in the following order: people, actions, settings: in other words, randomly choose one people string, then randomly choose one action string, then randomly choose one settings string, and print them all out as one string.

- A main method that creates a Headlines object, prints out a headline, then prompts the user to see whether or not to continue; the program should continue to run as long as the user chooses to see more, and terminates when the user chooses to quit.

Explanation / Answer

import java.io.*; import java.util.*; public class Headlines{ private int maxSize = 12; private String[] settings = new String[maxSize]; private String[] people = new String[maxSize]; private String[] actions = new String[maxSize]; private String settingsFileName = "settings.txt"; private String actionsFileName = "actions.txt"; private String peopleFileName = "people.txt"; private Double random = Math.random(); private int index = 0; public void readActions(String filename) throws FileNotFoundException, IOException{ FileInputStream fstream = new FileInputStream(filename); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line int i=0; while ((strLine = br.readLine()) != null && i