EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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
QUESTION 2 A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6.   Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the method in a complete program.   Tip: Recall that the % operator divides one number by another, and returns the remainder of the division. In an expression such as num1 % num2, the % operator will return 0 if num1 is evenly divisible by num2. QUESTION 3 Use the isPrime method that you wrote in previous question in a program that stores a list of all the prime numbers from 1 through 100 in a file.
QUESTION 2 A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6.   Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the method in a complete program.   Tip: Recall that the % operator divides one number by another, and returns the remainder of the division. In an expression such as num1 % num2, the % operator will return 0 if num1 is evenly divisible by num2. QUESTION 3 Use the isPrime method that you wrote in previous question in a program that stores a list of all the prime numbers from 1 through 100 in a file. plz answer these  question using java
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,…
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