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

I want this Java program as soon as possible and this is the Stock.txt. file imp

ID: 3720972 • Letter: I

Question

I want this Java program as soon as possible

and this is the Stock.txt. file

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Random;
import java.util.Scanner;

public class WriteStringsToFile {
public static void main(String args[]) throws FileNotFoundException, UnsupportedEncodingException {
String data[] = {"IBM, International Business Machines Corporation, 144.84, 5/2/2016",
"AAPL, Apple Inc. 92.63, 5/2/2016",
"ORCL, Oracle Corporation, 45.96,4/26/2018",
"CSCO, Cisco Systems, 44.21, 4/26/2018"};
PrintWriter writer = new PrintWriter("stocks.txt", "UTF-8");
int res;
for(int i = 0;i<data.length;i++){
writer.write(data[i]);
writer.write("/n");
}
writer.close();
}
}

please let me know if anything else is missing

Write a program to read data from the file stock.txt. for each line of data create an object of Stock class and store them in 1) ArrayList 2) a hash map as HashMap. The key will be the Symbol field (like IBM or CSCO) 3) Ask user to enter the symbol 4) Call a method searchArrayList(ArrayList, symbol) to search the ArrayList for the Symbol and return the price 5) Call a method searyHash(Hash,symbol) to search the Hash for the symbol and return the price 6) Call method printArrayList to print all the information of Stock 7) Call method printHash to print all the information of Stock in 8) Add one more Stock (ORCL, Oracle Corporation, 45.96, 9) Call method printArrayList to print all the information of Stock 10) Call method printHash to print all the information of in sorted order of Symbol sorted order of Symbol 4/26/2018) to both ArraList and HashMap in sorted order of Symbol Stock in sorted order of Symbol

Explanation / Answer

Hi

I have modified the code

WriteStringsToFile.java

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.ObjectOutputStream;

public class WriteStringsToFile {

public static void main(String args[]) throws IOException {

Stock data[] = {new Stock("IBM", "International Business Machines Corporation", 144.84, "5/2/2016"),

new Stock("AAPL", "Apple Inc.", 92.63, "5/2/2016"),

new Stock("ORCL", "Oracle Corporation", 45.96,"4/26/2018"),

new Stock("CSCO", "Cisco Systems", 44.21, "4/26/2018")};

File file = new File("stock.txt");

FileOutputStream fout = new FileOutputStream(file);

ObjectOutputStream oos = new ObjectOutputStream(fout);

for(int i = 0;i<data.length;i++){

oos.writeObject(data[i]);

}

oos.flush();

oos.close();

}

}

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