Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Having a few more issues with my homework in debugging it all and making it work entirely. PERSONTESTER.JAVA___ import java.util.*; import java.io.*; public class PersonTester

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Having a few more issues with my homework in debugging it all and making it work entirely.

PERSONTESTER.JAVA___

import java.util.*;

import java.io.*;

public class PersonTester extends Person

{

public static void main(String[] args) throws IOException

{ String text = null; String a = "data1.txt"; Scanner read=new Scanner(new File(a)); // BufferedReader brst = new BufferedReader(new FileReader(a)); //text = brst.readLine(); int aSize = Integer.parseInt(read.nextLine()); System.out.println(aSize); Student[] students=new Student[aSize]; int i=0;

while(read.hasNext())

{

Student s=new Student(); s.name=read.next(); s.age=read.nextInt(); s.id = read.nextInt(); s.major = read.next(); students[i]=s; i++;

} sortStudents(students); System.out.println(Arrays.toString(students)); }

//Scanner in=new Scanner(new File(b)); // int bSize = Integer.parseInt(in.nextLine()); //System.out.println(bSize); //same for DATA2.txt just like data1.txt //same for data2.txt

public static void sortStudents(Student students[])

{ int size = students.length; for (int p=1; p { Student key = students[p]; int q = p-1; while (q>=0 && students[q].compareTo(key)==1) { students[q+1] = students[q]; q = q-1; } students[q+1] = key; } } }

STUDENT.JAVA____

import java.io.*; import java.util.*; public class Student extends Person { private String major; private int sId; public Student(String n, int age, int d, String m) { super(n, age); major = m; sId = d; } public int getID(){ return sId; } public String getMajor(){ return major; } public void setID(){ this.sId = sId; } public void setMajor(){ this.major = major; } public String toString() { return "Student[super=" + super.toString() + ",major=" + major + "]"; } }

INSTRUCTOR______

import java.util.*; import java.io.*; public class Instructor extends Person { private double salary; private int result; public Instructor(String n, int age, double s) { super(n, age); salary = s; } public double getSalary(){ return salary; } public void setSalary(){ this.salary = salary; } public String toString() { { return "Employee[" + super.toString() + ",salary=" + salary + "]"; } } }

PERSON___(THIS CLASS CAN NOT CHANGE)

public class Person { private String name; private int age;

public Person() { name=""; age=0; } /** Create a person with a given name and age. @param name the name @param age the age */ public Person(String name, int age) { this.name = name; this.age = age; }

/** Get the name. @return the name */ public String getName() { return name; } /** Change the name. @param name the name */ public void setName(String name) { this.name = name; } /** Get the age. @return the age */ public int getAge() { return age; } /** Change the age. @param age the age */ public void setAge() { this.age = age; } /** Convert person to string form. */ public String toString() { return "Name: " + name + "\t" + "Age: " + age; } }

data1.bt-Notepad File Edit Format View Help Larry Amy Ashley ohn Eric Jennifer Christina Mike 28 23 18 17 19 20 19 21 12345 CPSC 34343 IT 99923 ENGL 23434 CPSE 33333 Biology 5555 French 7:39 PM 41) 11/1/2017 ^

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

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions