SlideShare a Scribd company logo
1 of 7
How do I get Main.java to compile, the program is
incomplete ? Need a complete program in Java. Thanks!
Class 3 Chapter 17 (Store data in a file)
Due Wednesday by 8pm Points 10 Submitting a file upload Available Feb 8 at 7pm - Feb 15 at
8pm
Program 3.1 Requirements
Write/Read Test Program using RandomAccessFile and Objects
*Note you should be using methods for the code, everything should not just be dumped in the
main method.
Create a new binary data file using RandomAccessFile populate it with integers from 0 to 100
Read the integer binary file and print it to the screen with 10 numbers on each line
Update the integer binary file so that all of the even numbers are 2
Read the integer binary file and print it to the screen with 10 numbers on each line
Create a new binary data file using RandomAccessFile populate it with doubles from 0 to 100
Read the double binary file and print it to the screen with 10 numbers on each line
Update the double binary file so that all of the odd numbers are 1
Read the double binary file and print it to the screen with 10 numbers on each line
Create a new binary data file using RandomAccessFile populate it with Strings "Hello", "Good
Morning", "Good Afternoon", "Good Evening"
Note: make all of the Strings the same size.
Read the String binary file and print each String on it's own line
Update the String binary file so that the last String says "Good Bye"
Read the String binary file and print each String on it's own line
Create a new binary data file using ObjectOutputStream
Use the Employee object from EmployeeManager Interface Part 1 to populate the file with the
data below:
1, 100, "John", "Wayne", Employee.EmployeeType.CONTRACTOR)
2, 1000.0, "Selina", "Kyle", Employee.EmployeeType.CONTRACTOR
Create a new binary data file using RandomAccessFile
Use the Employee object from EmployeeManager Interface Part 1 to populate the file with the
data below:
1, 100, "John", "Wayne", Employee.EmployeeType.CONTRACTOR)
2, 1000.0, "Selina", "Kyle", Employee.EmployeeType.CONTRACTOR
Example output:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
2, 1, 2, 3, 2, 5, 2, 7, 2, 9, 2,
11, 2, 13, 2, 15, 2, 17, 2, 19, 2,
21, 2, 23, 2, 25, 2, 27, 2, 29, 2,
31, 2, 33, 2, 35, 2, 37, 2, 39, 2,
41, 2, 43, 2, 45, 2, 47, 2, 49, 2,
51, 2, 53, 2, 55, 2, 57, 2, 59, 2,
61, 2, 63, 2, 65, 2, 67, 2, 69, 2,
71, 2, 73, 2, 75, 2, 77, 2, 79, 2,
81, 2, 83, 2, 85, 2, 87, 2, 89, 2,
91, 2, 93, 2, 95, 2, 97, 2, 99, 2,
0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0,
21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0,
31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0,
41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0,
51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0,
61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0,
71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0,
81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0,
91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0,
0.0, 1.0, 2.0, 1.0, 4.0, 1.0, 6.0, 1.0, 8.0, 1.0, 10.0,
1.0, 12.0, 1.0, 14.0, 1.0, 16.0, 1.0, 18.0, 1.0, 20.0,
1.0, 22.0, 1.0, 24.0, 1.0, 26.0, 1.0, 28.0, 1.0, 30.0,
1.0, 32.0, 1.0, 34.0, 1.0, 36.0, 1.0, 38.0, 1.0, 40.0,
1.0, 42.0, 1.0, 44.0, 1.0, 46.0, 1.0, 48.0, 1.0, 50.0,
1.0, 52.0, 1.0, 54.0, 1.0, 56.0, 1.0, 58.0, 1.0, 60.0,
1.0, 62.0, 1.0, 64.0, 1.0, 66.0, 1.0, 68.0, 1.0, 70.0,
1.0, 72.0, 1.0, 74.0, 1.0, 76.0, 1.0, 78.0, 1.0, 80.0,
1.0, 82.0, 1.0, 84.0, 1.0, 86.0, 1.0, 88.0, 1.0, 90.0,
1.0, 92.0, 1.0, 94.0, 1.0, 96.0, 1.0, 98.0, 1.0, 100.0,
Hello
Good Morning
Good Afternoon
Good Evening
//Store Data in a file
import java.io.*;
public class Main {
private static final int NUM_ELEMENTS = 100;
private static final int NUM_ELEMENTS_PER_LINE = 10;
private static final int STRING_LENGTH = 15;
public static void main(String[] args) throws IOException {
// Populate the integer binary file and print it to the screen
writeIntsToFile("ints.bin");
readIntsFromFile("ints.bin");
// Update the integer binary file and print it to the screen
updateIntsInFile("ints.bin");
readIntsFromFile("ints.bin");
// Populate the double binary file and print it to the screen
writeDoublesToFile("doubles.bin");
readDoublesFromFile("doubles.bin");
// Update the double binary file and print it to the screen
updateDoublesInFile("doubles.bin");
readDoublesFromFile("doubles.bin");
// Populate the String binary file and print it to the screen
writeStringsToFile("strings.bin");
readStringsFromFile("strings.bin");
// Update the String binary file and print it to the screen
updateStringsInFile("strings.bin");
readStringsFromFile("strings.bin");
// Populate the Object binary file using ObjectOutputStream and print it to the screen
writeEmployeesToFileUsingObjectOutputStream("employees_oos.bin");
readEmployeesFromFileUsingObjectInputStream("employees_oos.bin");
// Populate the Object binary file using RandomAccessFile and print it to the screen
writeEmployeesToFileUsingRandomAccessFile("employees_raf.bin");
readEmployeesFromFileUsingRandomAccessFile("employees_raf.bin");
}
private static void writeIntsToFile(String fileName) throws IOException {
try (RandomAccessFile file = new RandomAccessFile(fileName, "rw")) {
for (int i = 0; i < NUM_ELEMENTS; i++) {
file.writeInt(i);
}
}
}
private static void readIntsFromFile(String fileName) throws IOException {
try (RandomAccessFile file = new RandomAccessFile(fileName, "r")) {
for (int i = 0; i < NUM_ELEMENTS; i++) {
if (i % NUM_ELEMENTS_PER_LINE == 0) {
System.out.println();
}
System.out.print(file.readInt() + ", ");
}
System.out.println();
}
}
private static void updateIntsInFile(String fileName) throws IOException {
try (RandomAccessFile file = new RandomAccessFile(fileName, "rw")) {
for (int i = 0; i < NUM_ELEMENTS; i++) {
file.seek(i * Integer.BYTES);
int value = file.readInt();
if (value % 2 == 0) {
file.seek(i * Integer.BYTES);
file.writeInt(2)
// incomplete program above , how do I fix?
package examplesweek2;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Program employee implements Employee Manager File Implementation.
*
* @author
*/
public class EmployeeManagerFileImpl implements EmployeeManager {
private List<Employee> employees = new ArrayList<>();
private final String fileName = "employees.csv";
/**
* Method create employee, creates employees.
*/
@Override
public Employee createEmployee(Employee employee) {
employee.setId(employees.size() + 1);
employees.add(employee);
writeToFile();
return employee;
}
/**
* Method update employee, updates an employee.
*/
@Override
public Employee updateEmployee(Employee employee) {
int index = employee.getId() - 1;
employees.set(index, employee);
writeToFile();
return employee;
}
/**
* Method read employee, reads an employee.
*/
@Override
public Employee readEmployee(int id) {
int index = id - 1;
return employees.get(index);
}
/**
* Method read all employees, reads all employees.
*/
@Override
public List<Employee> readAllEmployees() {
return employees;
}
/**
* Method delete employee, deletes an employee.
*/
@Override
public void deleteEmployee(int id) {
int index = id - 1;
employees.remove(index);
writeToFile();
}
/**
* Method write to file, writes to file.
*/
private void writeToFile() {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
for (Employee employee : employees) {
writer.write(employee.getId() + "," + employee.getFirstName() +
"," + employee.getLastName() + ","
+ employee.getPayPerHour() + "," + employee.getEmployeeType());
writer.newLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Method reads from a file.
*/
private void readFromFile() {
try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {
String line;
while ((line = reader.readLine()) != null) {
String[] values = line.split(",");
int id = Integer.parseInt(values[0]);
String firstName = values[1];
String lastName = values[2];
double payPerHour = Double.parseDouble(values[3]);
EmployeeType employeeType = EmployeeType.valueOf(values[4]);
Employee employee = new Employee(id, firstName, lastName, payPerHour, employeeType);
employees.add(employee);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

More Related Content

Similar to How do I get Main-java to compile- the program is incomplete - Need.docx

Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud CastlesBen Scofield
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorialKaty Slemon
 
FileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docxFileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docxssuser454af01
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docxtheodorelove43763
 
Persistent mobile JavaScript
Persistent mobile JavaScriptPersistent mobile JavaScript
Persistent mobile JavaScriptYorick Phoenix
 
Sphinx autodoc - automated api documentation - PyCon.MY 2015
Sphinx autodoc - automated api documentation - PyCon.MY 2015Sphinx autodoc - automated api documentation - PyCon.MY 2015
Sphinx autodoc - automated api documentation - PyCon.MY 2015Takayuki Shimizukawa
 
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitPenetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitJongWon Kim
 
Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)
Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)
Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)Takayuki Shimizukawa
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in pythonAndrés J. Díaz
 
2017-06-22 Documentation as code
2017-06-22 Documentation as code2017-06-22 Documentation as code
2017-06-22 Documentation as codeJérémie Bresson
 
Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Toru Furukawa
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02PL dream
 
Flutter festival - building ui's with flutter
Flutter festival - building ui's with flutterFlutter festival - building ui's with flutter
Flutter festival - building ui's with flutterApoorv Pandey
 

Similar to How do I get Main-java to compile- the program is incomplete - Need.docx (20)

Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
 
General Functions
General FunctionsGeneral Functions
General Functions
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
NestJS
NestJSNestJS
NestJS
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorial
 
FileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docxFileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docx
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
 
Persistent mobile JavaScript
Persistent mobile JavaScriptPersistent mobile JavaScript
Persistent mobile JavaScript
 
Sphinx autodoc - automated api documentation - PyCon.MY 2015
Sphinx autodoc - automated api documentation - PyCon.MY 2015Sphinx autodoc - automated api documentation - PyCon.MY 2015
Sphinx autodoc - automated api documentation - PyCon.MY 2015
 
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitPenetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
 
Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)
Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)
Sphinx autodoc - automated API documentation (EuroPython 2015 in Bilbao)
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
2017-06-22 Documentation as code
2017-06-22 Documentation as code2017-06-22 Documentation as code
2017-06-22 Documentation as code
 
Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012
 
UNO based ODF Toolkit API
UNO based ODF Toolkit APIUNO based ODF Toolkit API
UNO based ODF Toolkit API
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
 
Flutter festival - building ui's with flutter
Flutter festival - building ui's with flutterFlutter festival - building ui's with flutter
Flutter festival - building ui's with flutter
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
 

More from Juliang56Parsonso

How is the process of recoding defined- (a) technique where the value.docx
How is the process of recoding defined- (a) technique where the value.docxHow is the process of recoding defined- (a) technique where the value.docx
How is the process of recoding defined- (a) technique where the value.docxJuliang56Parsonso
 
How is cognitive therapy different from rational-emotive therapy- Mult.docx
How is cognitive therapy different from rational-emotive therapy- Mult.docxHow is cognitive therapy different from rational-emotive therapy- Mult.docx
How is cognitive therapy different from rational-emotive therapy- Mult.docxJuliang56Parsonso
 
how has Information Systems impacted organizations- Research ways an o.docx
how has Information Systems impacted organizations- Research ways an o.docxhow has Information Systems impacted organizations- Research ways an o.docx
how has Information Systems impacted organizations- Research ways an o.docxJuliang56Parsonso
 
How is acid rain produced- CO2 molecules react with H2O molecules in t.docx
How is acid rain produced- CO2 molecules react with H2O molecules in t.docxHow is acid rain produced- CO2 molecules react with H2O molecules in t.docx
How is acid rain produced- CO2 molecules react with H2O molecules in t.docxJuliang56Parsonso
 
How Effective Managers Use Information Systems Advances in computer-ba.docx
How Effective Managers Use Information Systems Advances in computer-ba.docxHow Effective Managers Use Information Systems Advances in computer-ba.docx
How Effective Managers Use Information Systems Advances in computer-ba.docxJuliang56Parsonso
 
How do you think firms decide which type of private debts to use- Do t.docx
How do you think firms decide which type of private debts to use- Do t.docxHow do you think firms decide which type of private debts to use- Do t.docx
How do you think firms decide which type of private debts to use- Do t.docxJuliang56Parsonso
 
How does excess CO2 emission cause the reduction of coral reefs around.docx
How does excess CO2 emission cause the reduction of coral reefs around.docxHow does excess CO2 emission cause the reduction of coral reefs around.docx
How does excess CO2 emission cause the reduction of coral reefs around.docxJuliang56Parsonso
 
How do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docx
How do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docxHow do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docx
How do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docxJuliang56Parsonso
 
How do you change a column to an existing table in MS SQL Server- d- M.docx
How do you change a column to an existing table in MS SQL Server- d- M.docxHow do you change a column to an existing table in MS SQL Server- d- M.docx
How do you change a column to an existing table in MS SQL Server- d- M.docxJuliang56Parsonso
 
How do positively charged ions reach the upper portion of a thundersto.docx
How do positively charged ions reach the upper portion of a thundersto.docxHow do positively charged ions reach the upper portion of a thundersto.docx
How do positively charged ions reach the upper portion of a thundersto.docxJuliang56Parsonso
 
How do Palmer and hooks define vocation and purpose- Did they encounte.docx
How do Palmer and hooks define vocation and purpose- Did they encounte.docxHow do Palmer and hooks define vocation and purpose- Did they encounte.docx
How do Palmer and hooks define vocation and purpose- Did they encounte.docxJuliang56Parsonso
 
How do mobility barriers affect the strategy of a firm- They create is.docx
How do mobility barriers affect the strategy of a firm- They create is.docxHow do mobility barriers affect the strategy of a firm- They create is.docx
How do mobility barriers affect the strategy of a firm- They create is.docxJuliang56Parsonso
 
How do positively charged ions reach the upper portion of a thundersto (1).docx
How do positively charged ions reach the upper portion of a thundersto (1).docxHow do positively charged ions reach the upper portion of a thundersto (1).docx
How do positively charged ions reach the upper portion of a thundersto (1).docxJuliang56Parsonso
 
How can you integrate Machine learning and AI to improve security- Wha.docx
How can you integrate Machine learning and AI to improve security- Wha.docxHow can you integrate Machine learning and AI to improve security- Wha.docx
How can you integrate Machine learning and AI to improve security- Wha.docxJuliang56Parsonso
 
How do axial filaments differ from regular bacterial flagella- a- The.docx
How do axial filaments differ from regular bacterial flagella- a-  The.docxHow do axial filaments differ from regular bacterial flagella- a-  The.docx
How do axial filaments differ from regular bacterial flagella- a- The.docxJuliang56Parsonso
 
How can the money supply expand or shrink- How does the money supply r.docx
How can the money supply expand or shrink- How does the money supply r.docxHow can the money supply expand or shrink- How does the money supply r.docx
How can the money supply expand or shrink- How does the money supply r.docxJuliang56Parsonso
 
How big of a cash dividend needs to be declared to give the common sto.docx
How big of a cash dividend needs to be declared to give the common sto.docxHow big of a cash dividend needs to be declared to give the common sto.docx
How big of a cash dividend needs to be declared to give the common sto.docxJuliang56Parsonso
 
How are Mass and Matter related- None of these is the correct answer-.docx
How are Mass and Matter related- None of these is the correct answer-.docxHow are Mass and Matter related- None of these is the correct answer-.docx
How are Mass and Matter related- None of these is the correct answer-.docxJuliang56Parsonso
 
Hoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docx
Hoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docxHoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docx
Hoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docxJuliang56Parsonso
 
Horizontal analysis refers to changes in financial statement numbers a.docx
Horizontal analysis refers to changes in financial statement numbers a.docxHorizontal analysis refers to changes in financial statement numbers a.docx
Horizontal analysis refers to changes in financial statement numbers a.docxJuliang56Parsonso
 

More from Juliang56Parsonso (20)

How is the process of recoding defined- (a) technique where the value.docx
How is the process of recoding defined- (a) technique where the value.docxHow is the process of recoding defined- (a) technique where the value.docx
How is the process of recoding defined- (a) technique where the value.docx
 
How is cognitive therapy different from rational-emotive therapy- Mult.docx
How is cognitive therapy different from rational-emotive therapy- Mult.docxHow is cognitive therapy different from rational-emotive therapy- Mult.docx
How is cognitive therapy different from rational-emotive therapy- Mult.docx
 
how has Information Systems impacted organizations- Research ways an o.docx
how has Information Systems impacted organizations- Research ways an o.docxhow has Information Systems impacted organizations- Research ways an o.docx
how has Information Systems impacted organizations- Research ways an o.docx
 
How is acid rain produced- CO2 molecules react with H2O molecules in t.docx
How is acid rain produced- CO2 molecules react with H2O molecules in t.docxHow is acid rain produced- CO2 molecules react with H2O molecules in t.docx
How is acid rain produced- CO2 molecules react with H2O molecules in t.docx
 
How Effective Managers Use Information Systems Advances in computer-ba.docx
How Effective Managers Use Information Systems Advances in computer-ba.docxHow Effective Managers Use Information Systems Advances in computer-ba.docx
How Effective Managers Use Information Systems Advances in computer-ba.docx
 
How do you think firms decide which type of private debts to use- Do t.docx
How do you think firms decide which type of private debts to use- Do t.docxHow do you think firms decide which type of private debts to use- Do t.docx
How do you think firms decide which type of private debts to use- Do t.docx
 
How does excess CO2 emission cause the reduction of coral reefs around.docx
How does excess CO2 emission cause the reduction of coral reefs around.docxHow does excess CO2 emission cause the reduction of coral reefs around.docx
How does excess CO2 emission cause the reduction of coral reefs around.docx
 
How do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docx
How do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docxHow do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docx
How do the concepts of -Cultural Relativism- and -Ethnocentrism- relat.docx
 
How do you change a column to an existing table in MS SQL Server- d- M.docx
How do you change a column to an existing table in MS SQL Server- d- M.docxHow do you change a column to an existing table in MS SQL Server- d- M.docx
How do you change a column to an existing table in MS SQL Server- d- M.docx
 
How do positively charged ions reach the upper portion of a thundersto.docx
How do positively charged ions reach the upper portion of a thundersto.docxHow do positively charged ions reach the upper portion of a thundersto.docx
How do positively charged ions reach the upper portion of a thundersto.docx
 
How do Palmer and hooks define vocation and purpose- Did they encounte.docx
How do Palmer and hooks define vocation and purpose- Did they encounte.docxHow do Palmer and hooks define vocation and purpose- Did they encounte.docx
How do Palmer and hooks define vocation and purpose- Did they encounte.docx
 
How do mobility barriers affect the strategy of a firm- They create is.docx
How do mobility barriers affect the strategy of a firm- They create is.docxHow do mobility barriers affect the strategy of a firm- They create is.docx
How do mobility barriers affect the strategy of a firm- They create is.docx
 
How do positively charged ions reach the upper portion of a thundersto (1).docx
How do positively charged ions reach the upper portion of a thundersto (1).docxHow do positively charged ions reach the upper portion of a thundersto (1).docx
How do positively charged ions reach the upper portion of a thundersto (1).docx
 
How can you integrate Machine learning and AI to improve security- Wha.docx
How can you integrate Machine learning and AI to improve security- Wha.docxHow can you integrate Machine learning and AI to improve security- Wha.docx
How can you integrate Machine learning and AI to improve security- Wha.docx
 
How do axial filaments differ from regular bacterial flagella- a- The.docx
How do axial filaments differ from regular bacterial flagella- a-  The.docxHow do axial filaments differ from regular bacterial flagella- a-  The.docx
How do axial filaments differ from regular bacterial flagella- a- The.docx
 
How can the money supply expand or shrink- How does the money supply r.docx
How can the money supply expand or shrink- How does the money supply r.docxHow can the money supply expand or shrink- How does the money supply r.docx
How can the money supply expand or shrink- How does the money supply r.docx
 
How big of a cash dividend needs to be declared to give the common sto.docx
How big of a cash dividend needs to be declared to give the common sto.docxHow big of a cash dividend needs to be declared to give the common sto.docx
How big of a cash dividend needs to be declared to give the common sto.docx
 
How are Mass and Matter related- None of these is the correct answer-.docx
How are Mass and Matter related- None of these is the correct answer-.docxHow are Mass and Matter related- None of these is the correct answer-.docx
How are Mass and Matter related- None of these is the correct answer-.docx
 
Hoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docx
Hoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docxHoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docx
Hoperer Recwvabien Sehedile The fotowing accepints were uninterbenaly.docx
 
Horizontal analysis refers to changes in financial statement numbers a.docx
Horizontal analysis refers to changes in financial statement numbers a.docxHorizontal analysis refers to changes in financial statement numbers a.docx
Horizontal analysis refers to changes in financial statement numbers a.docx
 

Recently uploaded

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

How do I get Main-java to compile- the program is incomplete - Need.docx

  • 1. How do I get Main.java to compile, the program is incomplete ? Need a complete program in Java. Thanks! Class 3 Chapter 17 (Store data in a file) Due Wednesday by 8pm Points 10 Submitting a file upload Available Feb 8 at 7pm - Feb 15 at 8pm Program 3.1 Requirements Write/Read Test Program using RandomAccessFile and Objects *Note you should be using methods for the code, everything should not just be dumped in the main method. Create a new binary data file using RandomAccessFile populate it with integers from 0 to 100 Read the integer binary file and print it to the screen with 10 numbers on each line Update the integer binary file so that all of the even numbers are 2 Read the integer binary file and print it to the screen with 10 numbers on each line Create a new binary data file using RandomAccessFile populate it with doubles from 0 to 100 Read the double binary file and print it to the screen with 10 numbers on each line Update the double binary file so that all of the odd numbers are 1 Read the double binary file and print it to the screen with 10 numbers on each line Create a new binary data file using RandomAccessFile populate it with Strings "Hello", "Good Morning", "Good Afternoon", "Good Evening" Note: make all of the Strings the same size. Read the String binary file and print each String on it's own line Update the String binary file so that the last String says "Good Bye" Read the String binary file and print each String on it's own line Create a new binary data file using ObjectOutputStream Use the Employee object from EmployeeManager Interface Part 1 to populate the file with the data below: 1, 100, "John", "Wayne", Employee.EmployeeType.CONTRACTOR) 2, 1000.0, "Selina", "Kyle", Employee.EmployeeType.CONTRACTOR Create a new binary data file using RandomAccessFile Use the Employee object from EmployeeManager Interface Part 1 to populate the file with the data below: 1, 100, "John", "Wayne", Employee.EmployeeType.CONTRACTOR) 2, 1000.0, "Selina", "Kyle", Employee.EmployeeType.CONTRACTOR Example output:
  • 2. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 2, 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2, 17, 2, 19, 2, 21, 2, 23, 2, 25, 2, 27, 2, 29, 2, 31, 2, 33, 2, 35, 2, 37, 2, 39, 2, 41, 2, 43, 2, 45, 2, 47, 2, 49, 2, 51, 2, 53, 2, 55, 2, 57, 2, 59, 2, 61, 2, 63, 2, 65, 2, 67, 2, 69, 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2, 81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2, 97, 2, 99, 2, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0, 0.0, 1.0, 2.0, 1.0, 4.0, 1.0, 6.0, 1.0, 8.0, 1.0, 10.0, 1.0, 12.0, 1.0, 14.0, 1.0, 16.0, 1.0, 18.0, 1.0, 20.0, 1.0, 22.0, 1.0, 24.0, 1.0, 26.0, 1.0, 28.0, 1.0, 30.0, 1.0, 32.0, 1.0, 34.0, 1.0, 36.0, 1.0, 38.0, 1.0, 40.0, 1.0, 42.0, 1.0, 44.0, 1.0, 46.0, 1.0, 48.0, 1.0, 50.0, 1.0, 52.0, 1.0, 54.0, 1.0, 56.0, 1.0, 58.0, 1.0, 60.0, 1.0, 62.0, 1.0, 64.0, 1.0, 66.0, 1.0, 68.0, 1.0, 70.0, 1.0, 72.0, 1.0, 74.0, 1.0, 76.0, 1.0, 78.0, 1.0, 80.0, 1.0, 82.0, 1.0, 84.0, 1.0, 86.0, 1.0, 88.0, 1.0, 90.0, 1.0, 92.0, 1.0, 94.0, 1.0, 96.0, 1.0, 98.0, 1.0, 100.0, Hello Good Morning
  • 3. Good Afternoon Good Evening //Store Data in a file import java.io.*; public class Main { private static final int NUM_ELEMENTS = 100; private static final int NUM_ELEMENTS_PER_LINE = 10; private static final int STRING_LENGTH = 15; public static void main(String[] args) throws IOException { // Populate the integer binary file and print it to the screen writeIntsToFile("ints.bin"); readIntsFromFile("ints.bin"); // Update the integer binary file and print it to the screen updateIntsInFile("ints.bin"); readIntsFromFile("ints.bin"); // Populate the double binary file and print it to the screen writeDoublesToFile("doubles.bin"); readDoublesFromFile("doubles.bin"); // Update the double binary file and print it to the screen updateDoublesInFile("doubles.bin"); readDoublesFromFile("doubles.bin"); // Populate the String binary file and print it to the screen writeStringsToFile("strings.bin"); readStringsFromFile("strings.bin"); // Update the String binary file and print it to the screen updateStringsInFile("strings.bin"); readStringsFromFile("strings.bin"); // Populate the Object binary file using ObjectOutputStream and print it to the screen writeEmployeesToFileUsingObjectOutputStream("employees_oos.bin"); readEmployeesFromFileUsingObjectInputStream("employees_oos.bin"); // Populate the Object binary file using RandomAccessFile and print it to the screen writeEmployeesToFileUsingRandomAccessFile("employees_raf.bin"); readEmployeesFromFileUsingRandomAccessFile("employees_raf.bin"); }
  • 4. private static void writeIntsToFile(String fileName) throws IOException { try (RandomAccessFile file = new RandomAccessFile(fileName, "rw")) { for (int i = 0; i < NUM_ELEMENTS; i++) { file.writeInt(i); } } } private static void readIntsFromFile(String fileName) throws IOException { try (RandomAccessFile file = new RandomAccessFile(fileName, "r")) { for (int i = 0; i < NUM_ELEMENTS; i++) { if (i % NUM_ELEMENTS_PER_LINE == 0) { System.out.println(); } System.out.print(file.readInt() + ", "); } System.out.println(); } } private static void updateIntsInFile(String fileName) throws IOException { try (RandomAccessFile file = new RandomAccessFile(fileName, "rw")) { for (int i = 0; i < NUM_ELEMENTS; i++) { file.seek(i * Integer.BYTES); int value = file.readInt(); if (value % 2 == 0) { file.seek(i * Integer.BYTES); file.writeInt(2) // incomplete program above , how do I fix? package examplesweek2; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Program employee implements Employee Manager File Implementation. *
  • 5. * @author */ public class EmployeeManagerFileImpl implements EmployeeManager { private List<Employee> employees = new ArrayList<>(); private final String fileName = "employees.csv"; /** * Method create employee, creates employees. */ @Override public Employee createEmployee(Employee employee) { employee.setId(employees.size() + 1); employees.add(employee); writeToFile(); return employee; } /** * Method update employee, updates an employee. */ @Override public Employee updateEmployee(Employee employee) { int index = employee.getId() - 1; employees.set(index, employee); writeToFile(); return employee; } /** * Method read employee, reads an employee. */ @Override public Employee readEmployee(int id) { int index = id - 1; return employees.get(index); } /** * Method read all employees, reads all employees. */ @Override public List<Employee> readAllEmployees() { return employees; }
  • 6. /** * Method delete employee, deletes an employee. */ @Override public void deleteEmployee(int id) { int index = id - 1; employees.remove(index); writeToFile(); } /** * Method write to file, writes to file. */ private void writeToFile() { try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) { for (Employee employee : employees) { writer.write(employee.getId() + "," + employee.getFirstName() + "," + employee.getLastName() + "," + employee.getPayPerHour() + "," + employee.getEmployeeType()); writer.newLine(); } } catch (IOException e) { e.printStackTrace(); } } /** * Method reads from a file. */ private void readFromFile() { try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) { String line; while ((line = reader.readLine()) != null) { String[] values = line.split(","); int id = Integer.parseInt(values[0]); String firstName = values[1]; String lastName = values[2]; double payPerHour = Double.parseDouble(values[3]); EmployeeType employeeType = EmployeeType.valueOf(values[4]); Employee employee = new Employee(id, firstName, lastName, payPerHour, employeeType); employees.add(employee); } } catch (IOException e) { e.printStackTrace(); } }
  • 7. }