Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would I write a java program that reads a csv file. There are 22 lines of data in the file, each line having exactly

How would I write a java program that reads a csv file. There are 22 lines of data in the file, each line having exactly 4776 points of data. The first line says either "DP" or "CR"

The third line is the patients ID (1-21).

The rest of it is doubles.

import java.util.ArrayList;

public interface PatientCollectionADT {

public Patient getPatient (String id);

// Return the patient with the given id. Return void if the id does

// not exist in the collection

public Patient removePatient (String id);

// Remove and return the Patient with the given id. Return void if the id does not exist.

public void setResultForPatient (String id, String result);

// Set the result field for the patient with given id.

public ArrayList getIds ();

// Return an ArrayList with all of the collection's patient ids

public String addPatientsFromFile (String fileName);

// Method reads all lines from comma separated file named fileName.

// Each line must contain a unique patient identifier followed by exactly 4776 doubles.

// If the line does not meet the criteria, it is not added to the patient collection,

// and an error message is included in the return String.

// The error message will indicate which line was in error and what the error was.

// expected line format

//id,protein1,protein2, ... , protein4776

public String toString ();

// Return a String representation of the collection.

// Only include the 3697th and 3258th values in that order.

}

There also needs to be a predictor class that uses the 3697th and 3258th values in each patients data (in the order)

public class Predictor {

public static String predict (double p1, double p2) {

if (p1 <= 20.903959) {

return "predDP";

}

else {

if (p2<= 22.058599) {

return "predCR";

}

else {

return "predDP";

}

}

}

p1 is the 3697th and p2 is the 3258th.

So it needs to iterator through a csv file through that many commas and take those entries per patients, output in the stringtostring the patient id, CR or DP, the 3697 and 3258th piece of data.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions