Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Main.java: package com.company; import java.util.*; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System. in ); String fn =

image text in transcribed

Main.java:

package com.company; import java.util.*; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); String fn = stdin.next(); String ln = stdin.next(); double gpa = stdin.nextDouble(); int credits = stdin.nextInt(); Student student1 = new Student(fn, ln, gpa, credits); Student student2 = new Student(); student2.setFirstName("Joe"); student2.setLastName("Jones"); System.out.println("student1 = " + student1.getLastName() + ", " + student1.getFirstName() + " GPA = " + student1.getGPA() + " credits = " + student1.getCreditsEarned()); System.out.println("student2 = " + student2.getLastName() + ", " + student2.getFirstName() + " GPA = " + student2.getGPA() + " credits = " + student2.getCreditsEarned()); System.out.println(); System.out.println("How many students are attending UMW?"); int enrollment = stdin.nextInt(); ArrayList UMWStudents = new ArrayList(enrollment); UMWStudents.add(student1); for (int count = 0; count out.println("student = " + UMWStudents.get(count).getLastName() + ", " + UMWStudents.get(count).getFirstName() + " GPA = " + UMWStudents.get(count).getGPA() + " credits = " + UMWStudents.get(count).getCreditsEarned()); } } } 

Student.java:

package com.company; public class Student { protected String firstName; public String lastName; protected double GPA; protected int creditsEarned; public Student() { GPA = 0.0; creditsEarned = 0; } public Student (String first, String last, double gpa, int credits) { firstName = first; lastName = last; GPA = gpa; creditsEarned = credits; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public void setGPA (double GPA) { this.GPA = GPA; } public void setCreditsEarned (int creditsEarned) { this.creditsEarned = creditsEarned; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public double getGPA() { return GPA; } public int getCreditsEarned() { return creditsEarned; } } 
Adding on Add some additional methods to your main program to gain additional practice in using the ArrayList. Create a method that asks for a last name. Print a record of every student whose last name includes the specified character String. (Example: search for "Sm" would print students with both the last names Smith and Smuckers) Create a method that finds the student with the highest GPA and prints his/her name. If multiple students are tied for the highest GPA, print all students with the high value Adding on Add some additional methods to your main program to gain additional practice in using the ArrayList. Create a method that asks for a last name. Print a record of every student whose last name includes the specified character String. (Example: search for "Sm" would print students with both the last names Smith and Smuckers) Create a method that finds the student with the highest GPA and prints his/her name. If multiple students are tied for the highest GPA, print all students with the high value

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_2

Step: 3

blur-text-image_3

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions