Reference no: EM13158771
Write an application that allows you to enter any ID number and displays the first and last name for the record stored in the employee file with the given ID number. Display an appropriate message if the ID number cannot be found in the input file.
This is based on a comma-delimited text file that has already been created containing a 3 digit ID # and a first and last name. The last part of the excercise is as follows:
Write an application that allows you to enter any first name and displays all the
ID numbers and last names for any records stored in the employee file with the
given first name. Display an appropriate message if the first name cannot be
found in the input file.
Here's what I've got so far. It only displays the ID# and 000, , :
import java.nio.file.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
import java.util.Scanner;
public class DisplaySelectedIdNumbers {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
Path file
= Paths.get("C:\\Users\\Jeremiah\\Documents\\Test\\writeFile.txt");
String s = "000, , "
+ System.getProperty("line.separator");
final int RECSIZE = s.length();
byte[] data = s.getBytes();
ByteBuffer buffer = ByteBuffer.wrap(data);
FileChannel fc = null;
String idString;
int id;
try {
fc = (FileChannel) Files.newByteChannel(file, READ, WRITE);
System.out.print("Enter employee ID number ");
idString = keyBoard.nextLine();
id = Integer.parseInt(idString);
buffer = ByteBuffer.wrap(data);
fc.position(id * RECSIZE);
fc.read(buffer);
s = new String(data);
System.out.println("ID #" + id + " " + s);
fc.close();
} catch (Exception e) {
System.out.println("Error message: " + e);
}
}
}
Problem related to short-term notes payable
: On December 31, 2010, Irey Co. has $2,000,000 of short-term notes payable due on February 14, 2011. On January 10, 2011, Irey arranged a line of credit with County Bank which allows Irey to borrow up to $1,500,000 at one percent above the prime ra..
|
How many of the offspring would you expect to show
: Genes A/a and B/b are linked and known to be 20 map units apart. Individuals heterozygous for both of these genes (genotypes= AB/ab) were mated with each other. If there 2000 offspring from this cross, how many of the offspring would you expect to..
|
Explain the design of a public policy that would subsidize
: Explain the design of a public policy that would subsidize the private performance of the R&D (to ensure that the research is done by the private sector) yet would minimize the public funds used.
|
Struggle of the orders in early rome
: Discuss the class struggle between the Patricians and the Plebeians and the resulting Struggle of the Orders in early Rome. What rights did the Plebeians gain through this struggle?
|
Comma-delimited text file
: This is based on a comma-delimited text file that has already been created containing a 3 digit ID # and a first and last name. The last part of the excercise is as follows.
|
What kind of sons or daughters can they have
: An albino, non-hemophiliac man married a normally-pigmented, non-hemopheliac women; her father was a hemophiliac and her mother was an albino. What kind of sons/daughters can they have and in what proportion?
|
How do public goods and private goods compare
: how do public goods and private goods compare? open a supply and demand curve. in whcih direction do the shift if they both decease?
|
Segments of the hospitality and tourism industries
: Identify and describe the segments of the hospitality and tourism industries. Use examples to support your response
|
Describe what concentration in ppm would it constitute
: If all 0.44 gigatons CO2 remain in the atmosphere and spread around the atmosphere evenly, what concentration in ppm would it constitute?
|