Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#####JAVA CODE ##### Write codes to complete the following the two tasks for the provided codes: A. Find whether any student object with name Peter

#####JAVA CODE #####

Write codes to complete the following the two tasks for the provided codes: A. Find whether any student object with name Peter exists in the list using the contains method of the list object. Add required methods into the Student class to use the contains method

B. Now sort the list in descending order of CGPA using Comparator

image text in transcribed

Question 5 Write codes to complete the following the two tasks for the provided codes: A. Find whether any student object with name "Peter" exists in the list using the contains method of the "list" object. Add required methods into the Student" class to use the contains method B. Now sort the "list" in descending order of CGPA using Comparator class Student { String name; int id; double cgpa; public class Main { public static void main(String[] args) { ArrayList list = new ArrayList(); public Student (String name, int id, double cgpa) { this.name = name; this.id = id; this.cgpa = cgpa; } list.add(new Student ("Wizard", 3, 3.88)); list.add(new Student ("Peter", 2, 3.5)); list.add(new Student ("Wanda", 1, 3.88)); list.add(new Student ("Thanos", 41, 3.9)); list.add(new Student ("Yelena", 7, 3.75)); list.add(new Student ("Thor", 15, 3.89)); } public Student (String name) { this.name = name; this.id = -1; this.cgpa -1; }

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

Students also viewed these Databases questions