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”...
Trending nowThis is a popular solution!
Chapter 3 Solutions
EBK JAVA PROGRAMMING
- USE JAVA IDE Create a class that has three methods. One method is to input three numbers. The second method will return the largest number between the three numbers. The third method will return the smallest number between the three numbers. Since the largest and smallest number are both returned values, display these values in the main method.arrow_forwardhttps://youtu.be/4hAoK54Pfdc Here is a video regarding the kit component.arrow_forwardImage 1 is my code, and image 2 is how to calculate the score. i need to write 2 methods (Inalready wrote the method 3) Method 3: A method to collect the required patient information (age, zip code, insurance information, pain level, and temperature) and compute the priority score takes one Scanner parameter returns the computed score Method 4: A method to calculate the priority score of the patient (this method should be called in the method 3) takes five parameters, once for each patient feature returns the computed scorearrow_forward
- Chapter 5. PC #13. isPrime Method 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. The program should ask the user to enter a number for primality test or a negative number to exit. 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. Test Case 1 Please enter a number to check for primality or -1 to exit:\n2ENTER2 is a prime number.\nPlease enter a number to check for primality or -1 to exit:\n3ENTER3 is a prime number.\nPlease enter a…arrow_forwardWrite and test a method that can be used to determine the winner and increment either the user or the computer score for a round of Rock Paper Scissors. Please note that you are NOT being asked to write the entire Rock Paper Scissors game. You can assume that you have the following GLOBAL constants: ROCK, PAPER, SCISSORS, USERWINNER, COMPUTERWINNER. The method should be called DetermineWinner. It should take as parameters an integer that represents the user's move as well as an integer that represents the computer's move. Neither of these parameters will be changed by the method. It will take 2 additional parameters that may be edited by the method, an int that represents the user's score and another int that represents the computer's score. It will return an integer either USERWINNER or COMPUTERWINNER.arrow_forwardWrite a main method, in which you should have an Arralylist of students, in which you should include every student. You should have a PhD student named Joe Smith. In addition, you should create an Undergraduate student object for each of your team members (setting their names). If you’re only one person doing the assignment, then you should just create one undergraduate object. For each undergraduate student, you should add add two courses (COIS 2240 and COIS 1020). Loop over the arraylist of students, print their names, if the student is an undergraduate student, print their courses.arrow_forward
- In this programming question, you are required to implement five methods according to the following instructions. subtractBigInteger() – When an integer has more than a certain number of digits, it is represented using scientific notation. The int type itself cannot be used to store numbers with more than 10 digits. In some cases, this may be inconvenient as people usually expect complete numbers and doing big integer computations are inevitable. This method takes two numbers as CharStacks num1 and num2, and subtract the number stored in num2 from the one stored in num1, i.e., num1 - num2. To simply implementation, you can assume that the number stored in num1 is no less than the number stored in num2. For example, when subtracting 181,749 from 314,739,847, the two stacks and the result stack would look like the following: '7' low digit '4' '3' high digit '1' '8''9' '9' '5' '3' '4' '5' '7' '7' '8' '4' '4' high digit '1' '1' '3' num1 '0' low digit '8' '9' '1'…arrow_forwardJava programming please Support computing sales tax in the CashRegister class. The tax rate should be supplied when constructing a CashRegister object. Add recordTaxablePurchase and getTotalTax methods. (Amounts added with recordPurchase are not taxable.) The giveChange method should correctly reflect the sales tax that is charged on taxable items. Please add the method to the CashRegisterTester. The input and output are also provided below. CashRegister class: import java.util.Scanner; public class CashRegister { private double purchase; private double payment; /** Constructs a cash register with no money in it. */ public CashRegister() { purchase = 0; payment = 0; } /** Records the sale of an item. @param amount the price of the item */ public void recordPurchase(double amount) { purchase = purchase + amount; } /** Processes a payment received from the customer. @param amount the amount of the payment */…arrow_forwardUse java See the image for requirementsarrow_forward
- Please use Java as programming language Create a class whose main() holds two integer variables. Assign values to the variables. Create two methods named sum() and difference, that compute the sum and difference between the two variables respectively. Each method should perform the computation and display the results. In turn, call the two methods passing the values of the 2 variables. Create another method named product. The method should compute the product of the 2 numbers but will not display the answer. Instead, the method should return the answer to the calling main() which displays the answer. Provide your own screen display and class name.arrow_forwardJAVAWrite a program that calculates the average of courses, overall grade, and letter grade. Suppose that your students take four courses - English, Mathematics, Science, and History. You should design a class that accepts all four course's numeric scores, calculates average and overall grade, and decides letter grade based on the overall grade. Your class should have a constructor, get and set methods of each course, a method that calculates the average of four courses, a method that calculates overall grade, and a method that decides letter grade. The overall grades are calculated as the following rate: Average of All four courses: 50% Quiz: 40% Attendance: 10% The letter grade is based on the following: 90.0 to 100.0 - A 80.0 to 89.9 - B 70.0 to 79.9 - C 65.0 to 69.9 - D less than 65 - F Your program demonstrates the class by asking the user to input four-course numeric scores, creating an object, and then reporting each course's score, average, overall grade, and letter grade.…arrow_forwardIn python Add the following four methods to your Crew class: move(self, location): This takes in a location as a string, along with self, and attempts to move the crew member to the specified location. If location is one of the five valid location options ("Bridge", "Medbay", "Engine", "Lasers", or "Sleep Pods"), then this should change self.location to that new value. Otherwise, the function should print out the message: Not a valid location. repair(self, ship): first_aid(self, ship): fire_lasers(self, ship, target_ship, target_location): The above three methods represent tasks that a basic Crew member is not capable of (but one of its derived classes will be able to accomplish). So each of them should simply print out a message of the form: <Name> doesn't know how to do that. Examples: Copy the following if __name__ == "__main__" block into your hw12.py file, and comment out tests for parts of the class you haven’t implemented yet. if __name__ == '__main__': crew1…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,