Questions
The structure of the physician's service market has resulted in the development of the supplier-induced demand...

The structure of the physician's service market has resulted in the development of the supplier-induced demand hypothesis to explain conduct in the market. In at least a 250 word posting, discuss the theoretical and empirical issues surrounding the supplier-induced demand hypothesis.

In: Economics

1-Explain the empirical rule in your own words. How many standard deviations would it take for...

1-Explain the empirical rule in your own words. How many standard deviations would it take for you to consider a value to be statistically different?

2- Explain the four different types of sampling and give an example of each.

In: Statistics and Probability

********PLEASE ANSWER************* there are 31.4g sample of an unknown hydrocarbon sample containing only C, H, and...

********PLEASE ANSWER*************

there are 31.4g sample of an unknown hydrocarbon sample containing only C, H, and O. if those 31.4g are burned completely in O2 and gives 92.4g of CO2 and 27.0g of H2O, what is the empirical formula of the unknown compound?

In: Chemistry

It is commonly argued that fewer risk factors (as compared to the stock market) explain expected...

It is commonly argued that fewer risk factors (as compared to the stock market) explain expected returns in bonds. Indicate the main risk factors that empirical studies on the performance evaluation of bond funds consider and explain the risks they aim to capture.

In: Finance

Show in a formal mathematical proof, theoretical analysis, substitution method, an even split of an array...

Show in a formal mathematical proof, theoretical analysis, substitution method, an even split of an array into two subarrays which answers in the best performance of quicksort algorithm "appraised with respect to the running time". coding or empirical investigation are not needed.

In: Computer Science

You flip the same coin 900 mores times (1000 total flips). If half of the 900...

You flip the same coin 900 mores times (1000 total flips). If half of the 900 additional flips are heads and half are tails, what is the empirical probability of getting a heads for this coin? (505 heads in 1000 flips)

In: Statistics and Probability

1. With respect to resizable arrays, establish the relationship between the size of the array and...

1. With respect to resizable arrays, establish the relationship between the size of the array and the time it takes to perform random access (read a the value stored at a given position somewhere in the array). Provide empirical evidence to support your answer.

In: Computer Science

An unknown compound has a formula of CxHyOz. You burn .1523g of the compound and isolate...

An unknown compound has a formula of CxHyOz. You burn .1523g of the compound and isolate .3718g of CO2 and .1522 g of H2O. What is the empirical formula of the compound? if the molar mass is 72.1 g/mol, what is the molecular formula?

In: Chemistry

Below is the asset section of common-size balance sheets for Nike for a consecutive five-year period....

Below is the asset section of common-size balance sheets for Nike for a consecutive five-year period.   

      NIKE (NKE) 2019      2018     2017       2016        2015

Current Assets

Cash and Equivalents 15.8%    10.5%      9.4%       8.9%        5.2%

Receivables 25.7%    26.9%   31.3%     28.0%      27.9%

Inventories 20.6%    20.7%   22.6%     21.3%      24.5%

Other Current Assets 10.1% 11.8% 6.4% 6.2% 4.7%

Total Current Assets 72.2% 69.8%    69.7%      64.5%     62.3%

Non-Current Assets

P P & E, Net 18.3% 20.1% 24.1% 25.1% 27.8%

Intangibles                                6.2% 6.4% 2.7% 6.8%        6 .8%

Other Non-Curr Assets 3.4% 3.7% 3.4% 3.6% 3.1%

Total Non-Curr Assets 27.8% 30.2% 30.3% 35.5% 37.7%

Total Assets                          100.0% 100.0% 100.0%   100.0%    100.0%

Based on these statements alone, which of the following statements is most accurate?

Nike’s Debt consisted mostly of short-term debt in 2019.

Based on analysis of its assets, Nike was more liquid in 2019 than in 2015.

Nike had less money invested in inventory in 2019 than in 2015.

Nike had relatively more money invested in PP&E in 2019 than in 2015

In: Accounting

).Modify the project so that records are inserted into the random access file in ascending order...

).Modify the project so that records are inserted into the random access file in ascending order using an insertion sort methodology with the Social Security Number acting as the key value. This requires defining the method compareTo() in the Personal and Student classes to be used in a modified method add() in Database. The method finds a proper position for a record d, moves all the records in the file to make room for d, and writes d into the file.

2. With the new organization of the data files. find() and modify() must also be modified. Both methods should now stop their sequential search when they encounter a record greater than the record looked for, or they reach the end of the file.

Can somebody check the compareTo() and help me out with the add() method in this question.

Personal.java

import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Comparator;

public class Personal extends IOmethods implements DbObject, Comparable {
   protected final int nameLen = 10, cityLen = 10;
   protected String SSN, name, city;
   protected int year;
   protected long salary;
   protected final int size = 9 * 2 + nameLen * 2 + cityLen * 2 + 4 + 8;

   Personal() {
   }

   Personal(String ssn, String n, String c, int y, long s) {
       SSN = ssn;
       name = n;
       city = c;
       year = y;
       salary = s;
   }

   public int size() {
       return size;
   }

   public void writeToFile(RandomAccessFile out) throws IOException {
       writeString(SSN, out);
       writeString(name, out);
       writeString(city, out);
       out.writeInt(year);
       out.writeLong(salary);
   }

   public void writeLegibly() {
       System.out.print("SSN = " + SSN + ", name = " + name.trim() + ", city = " + city.trim() + ", year = " + year
               + ", salary = " + salary);
   }

   public void readFromFile(RandomAccessFile in) throws IOException {
       SSN = readString(9, in);
       name = readString(nameLen, in);
       city = readString(cityLen, in);
       year = in.readInt();
       salary = in.readLong();
   }

   public void readKey() throws IOException {
       System.out.print("Enter SSN: ");
       SSN = readLine();
   }

   public void readFromConsole() throws IOException {
       System.out.print("Enter SSN: ");
       SSN = readLine();
       System.out.print("Name: ");
       name = readLine();
       for (int i = name.length(); i < nameLen; i++)
           name += ' ';
       System.out.print("City: ");
       city = readLine();
       for (int i = city.length(); i < cityLen; i++)
           city += ' ';
       System.out.print("Birthyear: ");
       year = Integer.valueOf(readLine().trim()).intValue();
       System.out.print("Salary: ");
       salary = Long.valueOf(readLine().trim()).longValue();
   }

   public void copy(DbObject[] d) {
       d[0] = new Personal(SSN, name, city, year, salary);
   }

   // compare by ssn
   public static Comparator ssnComparator = new Comparator() {

       public int compare(Personal p1, Personal p2) {
           String ssnP1 = p1.SSN.toUpperCase();
           String ssnP2 = p2.SSN.toUpperCase();

           // ascending order
           return ssnP1.compareTo(ssnP2);

       }
   };

   @Override
   public int compareTo(Personal o) {

       if (Integer.parseInt(this.SSN) < Integer.parseInt(o.SSN)) {

           return -1;
       } else if (Integer.parseInt(this.SSN) > Integer.parseInt(SSN)) {

           return 1;
       } else {
           return 0;
       }

   }
}


Student.java

import java.io.*;

public class Student extends Personal {
public int size() {
return super.size() + majorLen*2;
}
protected String major;
protected final int majorLen = 10;
Student() {
super();
}
Student(String ssn, String n, String c, int y, long s, String m) {
super(ssn,n,c,y,s);
major = m;
}
public void writeToFile(RandomAccessFile out) throws IOException {
super.writeToFile(out);
writeString(major,out);
}
public void readFromFile(RandomAccessFile in) throws IOException {
super.readFromFile(in);
major = readString(majorLen,in);
}
public void readFromConsole() throws IOException {
super.readFromConsole();
System.out.print("Enter major: ");
major = readLine();
for (int i = major.length(); i < nameLen; i++)
major += ' ';
}
public void writeLegibly() {
super.writeLegibly();
System.out.print(", major = " + major.trim());
}
public void copy(DbObject[] d) {
d[0] = new Student(SSN,name,city,year,salary,major);
}
public int compareTo() {
  
}
}

DbObject.java

import java.io.*;

public interface DbObject {
   public void writeToFile(RandomAccessFile out) throws IOException;
public void readFromFile(RandomAccessFile in) throws IOException;
public void readFromConsole() throws IOException;
public void writeLegibly() throws IOException;
public void readKey() throws IOException;
public void copy(DbObject[] db);
public int size();
}

IOmethods,java

import java.io.*;

public class IOmethods {
public void writeString(String s, RandomAccessFile out) throws IOException {
for (int i = 0; i < s.length(); i++)
out.writeChar(s.charAt(i));
}
public String readString(int len, RandomAccessFile in) throws IOException {
String s = "";
for (int i = 0; i < len; i++)
s += in.readChar();
return s;
}
public String readLine() throws IOException {
int ch;
String s = "";
while (true) {
ch = System.in.read();
if (ch == -1 || (char)ch == '\n') // end of file or end of line;
break;
else if ((char)ch != '\r') // ignore carriage return;
s = s + (char)ch;
}
return s;
}
}
Database.java

import java.io.*;
public class Database {
   private RandomAccessFile database;
private String fName = new String();;
private IOmethods io = new IOmethods();
Database() throws IOException {
System.out.print("File name: ");
fName = io.readLine();
}
private void add(DbObject d) throws IOException {
database = new RandomAccessFile(fName,"rw");
database.seek(database.length());
d.writeToFile(database);
database.close();
}
private void modify(DbObject d) throws IOException {
DbObject[] tmp = new DbObject[1];
d.copy(tmp);
database = new RandomAccessFile(fName,"rw");
while (database.getFilePointer() < database.length()) {
tmp[0].readFromFile(database);
if (tmp[0].equals(d)) {
tmp[0].readFromConsole();
database.seek(database.getFilePointer()-d.size());
tmp[0].writeToFile(database);
database.close();
return;
}
}
database.close();
System.out.println("The record to be modified is not in the database");
}
private boolean find(DbObject d) throws IOException {
DbObject[] tmp = new DbObject[1];
d.copy(tmp);
database = new RandomAccessFile(fName,"r");
while (database.getFilePointer() < database.length()) {
tmp[0].readFromFile(database);
if (tmp[0].equals(d)) {
database.close();
return true;
}
}
database.close();
return false;
}
private void printDb(DbObject d) throws IOException {
database = new RandomAccessFile(fName,"r");
while (database.getFilePointer() < database.length()) {
d.readFromFile(database);
d.writeLegibly();
System.out.println();
}
database.close();
}
public void run(DbObject rec) throws IOException {
String option;
System.out.println("1. Add 2. Find 3. Modify a record; 4. Exit");
System.out.print("Enter an option: ");
option = io.readLine();
while (true) {
if (option.charAt(0) == '1') {
rec.readFromConsole();
add(rec);
}
else if (option.charAt(0) == '2') {
rec.readKey();
System.out.print("The record is ");
if (find(rec) == false)
System.out.print("not ");
System.out.println("in the database");
}
else if (option.charAt(0) == '3') {
rec.readKey();
modify(rec);
}
else if (option.charAt(0) != '4')
System.out.println("Wrong option");
else return;
printDb(rec);
System.out.print("Enter an option: ");
option = io.readLine();
}
}
}

UseDatabase.java

import java.io.IOException;

public class UseDatabase {
static public void main(String a[]) throws IOException {
// (new Database()).run(new Personal());
(new Database()).run(new Student());
}
}

In: Computer Science