Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * - - - - - - - - - - - - - - - - - - - - - - -

/*---------------------------------------------------------------------------
// AUTHOR:
// SPECIFICATION: This program is for practicing the use of classes, constructors,
// helper methods, and the this operator.
// INSTRUCTIONS: Read the following code skeleton and add your own code
// according to the comments
//-------------------------------------------------------------------------*/
import java.util.Scanner;
public class
{
public static void main(String[] args)
{
// Let's make two students using all two constructors
// Write code to create a new student alice using constructor #1
//-->
Student alice =
// Write code to create a new student bob with name "Bob Brown",
// age 23 and GPA 3.8 using constructor #2
//-->
// Let's get user input to change the missing or default values
Scanner scan = new Scanner(System.in);
// Get user input and set Alice's full name
System.out.print("Enter full name for Alice: ");
alice.setName(scan.nextLine());
// Get user input and set Alice's age
// Write code to get user input and set Alice's GPA
//-->
// Lets print out the students details
alice
bob
System.out.println("\r
Changing Bob's GPA");
// Get user input and change bob's gpa
// Write code to print out bob's new details
//-->
System.out.println("\r
Comparing Alice and Bob");
Student better = alice.betterGPA(bob);
System.out.println(better.getName()+" has a better GPA");
// Use the olderStudent method to figure out which student is
// older between Alice and Bob. Then print out the result. Follow
// the betterGPA example above.
//-->
// Finally, print out each student's details 3 times, using the print(int n) method
//-->
}

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 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions