The goal for Lab07 is to use the provided Student class and create an array of Student objects that is stored in a School object. This program uses a Student class that is provided(picture attached!). The class is placed in its own separate file and should not be altered. This project started with Lab06a and uses the same Student class. Part one of Lab07 is similar to the Lab06b. The difference is that Lab06b used static 1D arrays and Lab07 uses dynamic ArrayList arrays. The output is the same. In part two, adds the linearSearch and the binarySearch methods. Each search method is tested with an existing search record and one that does not exist.    Tom  21  1.685  Ann  34  3.875  Bob  18  2.5  Jan  45  4.0  Joe  27  2.975  Sue  19  3.225  Jay  30  3.65  Meg  38  2.0  Art  40  3.999  Deb  35  2.125  7  -1  Ann  34  3.875  Art  40  3.999  Bob  18  2.5  Deb  35  2.125  Jan  45  4.0  Jay  30  3.65  Joe  27  2.975  Meg  38  2.0  Sue  19  3.225  Tom  21  1.685  7  -1

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

The goal for Lab07 is to use the provided Student class and create an array of Student objects that is stored in a School object. This program uses a Student class that is provided(picture attached!). The class is placed in its own separate file and should not be altered. This project started with Lab06a and uses the same Student class.

Part one of Lab07 is similar to the Lab06b. The difference is that Lab06b used static 1D arrays and Lab07 uses dynamic ArrayList arrays. The output is the same.

In part two, adds the linearSearch and the binarySearch methods. Each search method is tested with an existing search record and one that does not exist.

 

 Tom  21  1.685
 Ann  34  3.875
 Bob  18  2.5
 Jan  45  4.0
 Joe  27  2.975
 Sue  19  3.225
 Jay  30  3.65
 Meg  38  2.0
 Art  40  3.999
 Deb  35  2.125

 7
 -1

 Ann  34  3.875
 Art  40  3.999
 Bob  18  2.5
 Deb  35  2.125
 Jan  45  4.0
 Jay  30  3.65
 Joe  27  2.975
 Meg  38  2.0
 Sue  19  3.225
 Tom  21  1.685

 7
 -1

 

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
// Labe6bvst.java
// This the Student Starting file for Lab06b.
public class Lab86bvst
{
}
public static void main (String[] args)
{
}
System.out.println("Labe6bv100 by ***** your name goes here****");
int size = 10;
School bhs = new School(size);
System.out.println(bhs);
bhs.bubbleSort1();
class School
{
System.out.println(bhs);
bhs.bubbleSort2();
System.out.println(bhs);
bhs.bubbleSort3();
System.out.println(bhs);
private Student[] students;
private int size;
}
/public School (int s)
String[] names = {"Tom", "Ann", "Bob", "Jan", "Joe", "Sue", "Jay", "Meg", "Art", "Deb"};
int[] ages = {21, 34, 18, 45, 27, 19, 30, 38, 40, 35};
double[] gpas (1.685, 3.875, 2.5, 4.0, 2.975, 3.225, 3.65, 2.0, 3.999, 2.125};
}
// Sorts by name
// Sorts by gpa
// Sorts by age
public void addData(String[] names, int[] ages, double[] gpas)
{
students = new Student [10];
addData(names, ages, gpas);
for (int i = 0; i <10; i++)
{
students [1] = new Student (names[i], ages[i], gpas[i]);
}
public String toString()
{
String output = "";
for (int i = 0; i < 10; i++)
{
output += students[i];
}
return output;
// Sorts by name
public void bubbleSorti() { /* To Be Completed */ }
Transcribed Image Text: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 // Labe6bvst.java // This the Student Starting file for Lab06b. public class Lab86bvst { } public static void main (String[] args) { } System.out.println("Labe6bv100 by ***** your name goes here****"); int size = 10; School bhs = new School(size); System.out.println(bhs); bhs.bubbleSort1(); class School { System.out.println(bhs); bhs.bubbleSort2(); System.out.println(bhs); bhs.bubbleSort3(); System.out.println(bhs); private Student[] students; private int size; } /public School (int s) String[] names = {"Tom", "Ann", "Bob", "Jan", "Joe", "Sue", "Jay", "Meg", "Art", "Deb"}; int[] ages = {21, 34, 18, 45, 27, 19, 30, 38, 40, 35}; double[] gpas (1.685, 3.875, 2.5, 4.0, 2.975, 3.225, 3.65, 2.0, 3.999, 2.125}; } // Sorts by name // Sorts by gpa // Sorts by age public void addData(String[] names, int[] ages, double[] gpas) { students = new Student [10]; addData(names, ages, gpas); for (int i = 0; i <10; i++) { students [1] = new Student (names[i], ages[i], gpas[i]); } public String toString() { String output = ""; for (int i = 0; i < 10; i++) { output += students[i]; } return output; // Sorts by name public void bubbleSorti() { /* To Be Completed */ }
1
AWNA
2
3
4
5
6
7
CHIENENGGANZE2222
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23
24
25
26
27
// Student.java
// Used by the Lab06 and Lab07 Assignments.
public class Student
{
}
private String name;
private int age;
private double gpa;
public Student (String n, int a, double g)
{
}
name = n;
age = a;
gpa g;
=
public String getName() { return name; }
public int getAge() { return age; }
public double getGPA()
{ return gpa; }
}
public String toString()
{
String temp = name +
return temp;
+ age +
+ gpa + "\n";
Transcribed Image Text:1 AWNA 2 3 4 5 6 7 CHIENENGGANZE2222 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 // Student.java // Used by the Lab06 and Lab07 Assignments. public class Student { } private String name; private int age; private double gpa; public Student (String n, int a, double g) { } name = n; age = a; gpa g; = public String getName() { return name; } public int getAge() { return age; } public double getGPA() { return gpa; } } public String toString() { String temp = name + return temp; + age + + gpa + "\n";
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT