Java Programming, Loose-leaf Version
Java Programming, Loose-leaf Version
8th Edition
ISBN: 9781337685917
Author: Joyce Farrell
Publisher: Cengage Learning
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 3, Problem 12PE

Explanation of Solution

a.

Program code:

Student.java

//define a class Student

class Student

{

//declare the class members

private String ID;

private int numberOfCredits;

private int points;

private double gradePoint;

//define the constructor

public Student()

{}

//define the constructor

public Student(String aID, int aNumberOfCredits, int aPoints)

{

//initialize the class members

super();

ID = aID;

numberOfCredits = aNumberOfCredits;

points = aPoints;

//call the method calculateGradePoint()

calculateGradePoint();

}

//define the method getID()

public String getID()

{

//return the value of ID

return ID;

}

//define the method setID()

public void setID(String aID)

{

//set the value of ID

ID = aID;

}

//define the method getNumberOfCredits()

public int getNumberOfCredits()

{

//return the value of numberOfCredits

return numberOfCredits;

}

//define the method setNumberOfCredits()

public void setNumberOfCredits(int aNumberOfCredits)

{

//set the value of numberOfCredits

numberOfCredits = aNumberOfCredits;

}

//define the method getPoints()

public int getPoints()

{

//return the value of points

return points;

}

//define the method setPoints()

public void setPoints(int aPoints)

{

//set the value of points

points = aPoints;

}

//define the method toString()

public String toString()

{

//return the value

return "ID : " + ID + " NumberOfCredits : " + numberOfCredits + " Points : " + points+" Grade Point : "+gradePoint;

}

//define the method calculateGradePoint()

public void calculateGradePoint()

{

//calculate the value of gradePoint

gradePoint=points/(double)numberOfCredits;

}

}

Explanation:

The above snippet of code is used create a class “Student”. The class contain different static methods for store the details of a student. In the code,

  • Define a class “Student”
    • Define the constructor “Student ()” method.
    • Define the constructor “Student ()” method.
      • Initialize the class members.
      • Call the method “calculateGradePoint()”.
    • Define the “getID()” method.
      • Return the value of the variable “ID”.
    • Define the “setID()” method.
      • Set the value of the variable “ID”.
    • Define the “getNumberOfCredits()” method.
      • Return the value of the variable “NumberOfCredits”...

Blurred answer
Students have asked these similar questions
Create a class named Student that has fields for an ID number, numberof credit hours earned, and number of points earned. (For example,many schools compute grade point averages based on a scale of 4, so athree-credit-hour class in which a student earns an A is worth 12 points.)Include methods to assign values to all fields. A Student also has a field forgrade point average. Include a method to compute the grade point averagefield by dividing points by credit hours earned. Write methods to display thevalues in each Student field. Save this class as Student.java.b. Write a class named ShowStudent that instantiates a Student object from theclass you created and assign values to its fields. Compute the Student gradepoint average, and then display all the values associated with the Student.Save the application as ShowStudent.java.c. Create a constructor for the Student class you created. The constructor shouldinitialize each Student’s ID number to 9999, his or her points earned to 12,…
3. Create a program for Smalltown Regional Airport Flights that accepts either an  integer flight number or string airport code from the options in Figure 8-33. Pass the user’s entry to one of two overloaded GetFlightInfo() methods, and then display a  returned string with all the flight details. The method version that accepts an integer looks up the airport code, name, and time of flight; the version that accepts a string description looks up the flight number, airport name, and time. The methods return an appropriate message if the flight is not found.  Farrell, Joyce. Microsoft Visual C#: An Introduction to Object-Oriented Programming (MindTap Course List) (p. 347). Cengage Learning. Kindle Edition.
Create a class named Checkup with fields that hold a patient number, two blood pressure figures (systolic and diastolic), and two cholesterol figures (LDL and HDL). Include methods to get and set each of the fields. Include a method named computeRatio() that divides LDL cholesterol by HDL cholesterol and displays the result. Include an additional method named explainRatio() that explains that HDL is known as “good cholesterol” and that a ratio of 3.5 or lower is considered optimum. Save the class as CheckupType.cpp. Create a tester program named TestCheckup whose main() method declares four Checkup objects. Call a getData() method four times. Within the method, prompt a user for values for each field for a Checkup, and return a Checkup object to the main() method where it is assigned to one of main()’s Checkup objects. Then, in main(), pass each Checkup object in turn to a showValues()method that displays the data. Blood pressure values are usually displayed with a slash between the…
Knowledge Booster
Background pattern image
Computer Science
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
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY