Examlex
import java.nio.file.*;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
import java.util.Scanner;
public class CreateEmployeesRandomFile
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Path file =
Paths.get("C:\\Java\\Chapter.13\\RandomEmployees.txt");
String s = "000, ,00.00" +
System.getProperty("line.separator");
final int RECSIZE = s.length();
FileChannel fc = null;
String delimiter = ",";
String idString;
int id;
String name;
String payRate;
final String QUIT = "999";
try
{
fc = (FileChannel)Files.newByteChannel(file, READ, WRITE);
System.out.print("Enter employee ID number >> ");
idString = input.nextLine();
while(!(idString.equals(QUIT)))
{
----Code here-----
System.out.print("Enter name for employee #" +
id + " >> ");
name = input.nextLine();
System.out.print("Enter pay rate >> ");
payRate = input.nextLine();
s = idString + delimiter + name + delimiter +
payRate + System.getProperty("line.separator");
byte[] data = s.getBytes();
ByteBuffer buffer = ByteBuffer.wrap(data);
----Code here-----
fc.write(buffer);
System.out.print("Enter next ID number or " +
QUIT + " to quit >> ");
idString = input.nextLine();
}
fc.close();
}
catch (Exception e)
{
System.out.println("Error message: " + e);
}
The above program will accept any number of employee records as user input and write the records to a file in a loop. In the first indicated line, create the statement to accept the employee data value from the keyboard as a String and convert it to an integer using the parseInt() method. In the second indicated line, create the statement to compute the record's desired position by multiplying the ID number value by the record size.
Beck's Cognitive
Beck's Cognitive Therapy, developed by Aaron T. Beck, is a therapeutic approach that identifies and changes negative and dysfunctional thoughts and beliefs to treat psychological disorders.
Psychotherapy
The treatment of mental disorder by psychological rather than medical means.
Research System
An organized set of principles and methodologies utilized for conducting research and generating new knowledge.
Personality Disorders
Mental disorders characterized by enduring maladaptive patterns of behavior, cognition, and inner experience, exhibited across many contexts and deviating from those accepted by the individual's culture.
Q2: According to natural law theory it would
Q5: A synonym for unethical is<br>A) Immoral<br>B) Illegal<br>C)
Q13: Label the following as examples of Utilitarian
Q21: Describe the purpose of an accelerator. Provide
Q21: If a person asks to be disconnected
Q21: Label the following as examples of the
Q26: The ratio of boys to girls in
Q27: You use the keyword _ to achieve
Q32: Label the following as Normative (N) or
Q50: Write the code for bubble sorting a