Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the StudentArrayDemo.java, student array accept student object as parameter: find the first student object information according to s1 object, to find his/her name, id,

In the StudentArrayDemo.java, student array accept student object as parameter:

find the first student object information

according to s1 object, to find his/her name, id, gpa

if there is given student's name, we need search this name and find this student is in the student array or not

find the highest GPA from student array

Student.java

public class Student { String name; int id; double gpa; Student(String n,int id,double gpa) { this.name = n; this.id = id; this.gpa = gpa; } public String getName() { return this.name; } public int getID() { return this.id; } public double getGPA() { return this.gpa; } }

StudentArrayDemo.java

import java.util.*;

public class StudentArrayDemo {

public static void main(String[] args) {

// 1. instantiate several student object with their known name, id and gpa Student s1 = new Student("John", 11111, 3.68); Student s2 = new Student("Allen", 22222, 3.57); Student s3 = new Student("Mary", 33333, 4.0); Student s4 = new Student("Alex", 44444, 3.57);

// 2. create a student array with initial student object information Student studentArray [] = {s1,s2,s3,s4};

// 3. output the student array information for ( int index = 0; index < studentArray.length; index ++ ) { System.out.println( studentArray [index] ); }

// 4. search student information in the array, and check this fruit is in the list or not // Q1. find the first student object information

// Q2. according to s1 object, to find his/her name, id, gpa

// Q3. if there is given student's name, // we need search this name and find this student // is in the student array or not Scanner scan = new Scanner(System.in); System.out.println(" Which student you want to search from student array? "); String typeName = scan.next();

// Q4. find the highest GPA from student array

}

}

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

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

8. Describe the steps in the development planning process.

Answered: 1 week ago