Concept explainers
Write a method called makeItNewYears that could be added to the class DateFirstTry in Display 4.1. The method makeItNewYears has no parameters and sets the month instance variable to "January" and the day instance variable to 1. It does not change the year instance variable.
Question reference: The method, makeItNewYears, which having the no parameter, also sets the instance variable named month to “January� and set the current day to 1.
Method Explanation:
The definition of the method, makeItNewYears, sets the value of month and day.
Month and day are the instance variables of class, DateFirstTry.
The method sets the month variable to January, the day variable to 1.
Explanation of Solution
Method:
//Method definition
public void makeItNewYears()
{
       month=�January�; //sets the month variable
      day=1; //sets the day variable
}
Want to see more full solutions like this?
Chapter 4 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Problem Solving with C++ (10th Edition)
Degarmo's Materials And Processes In Manufacturing
Starting Out with Python (4th Edition)
SURVEY OF OPERATING SYSTEMS
Management Information Systems: Managing The Digital Firm (16th Edition)
- Create a class called FinalGrade that is used to represent the points obtained in the letter grade of CSC 110 by different students. The FinalGrade class should include three pieces of information as instance variables—studentName (type String), studentID (type String), and pointsObtained (type int). Your class should have a constructor that initializes the three instance variables. Provide a set and a get method for each and every instance variable. In addition, provide a method named computeLetterGrade that returns the letter grade obtained by the student taking the pointsObtained as an argument. For the grading policy refer to CSC 110 grading scheme specified in syllabus. Write a test application named FinalGradeDriver that creates at least 3 different objects of class FinalGrade and test all the methods of class FinalGrade. Sample Output Student Name : Homer SimpsonStudent ID : S123456Points Obtained : 99Letter Grade : A Student Name : Marge SimpsonStudent ID : S234567Points…arrow_forwardCreate a new project for this program called TestOldMaid and add a class with a main() method. In the project: Copy your Deck and Card class from the earlier project into it. Create a subclass of Deck called OldMaidDeck. It is special because one of the Queens is missing so it only has 51 cards. Create a constructor method that calls the super class constructor, then removes a queen. Override the toString method so it returns the name of the deck and the number of cards in it. Write the test main() method. Create an OldMaidDeck object and deal all the cards to six players. It is ok if not everyone has an equal number of cards. Use arrays or ArrayLists for the players hands. Show the hands of all 6 players. Refer to the web to find out more about the Old Maid card game: https://bicyclecards.com/how-to-play/old-maid/ Fully document all classes with your name, date and description. And each data member and method is documented. Each block that does something is also documented.arrow_forwardCreate a new project for this program called TestOldMaid and add a class with a main() method. In the project: Copy your Deck and Card class from the earlier project into it. Create a subclass of Deck called OldMaidDeck. It is special because one of the Queens is missing so it only has 51 cards. Create a constructor method that calls the super class constructor, then removes a queen. Override the toString method so it returns the name of the deck and the number of cards in it. Write the test main() method. Create an OldMaidDeck object and deal all the cards to six players. It is ok if not everyone has an equal number of cards. Use arrays or ArrayLists for the players hands. Show the hands of all 6 players. Refer to the web to find out more about the Old Maid card game. Fully document all classes with your name, date and description. And each data member and method is documented. Each block that does something is also documented. Without removing the Queensarrow_forward
- Write a class Cylinder that contains information about a cylindrical object. The Cylinder class must have two instance variables: self.r is a floating point value describing the radius of the cylinder self.h is a floating point value describing the height of the cylinder The Cylinder class should also have a constructor and two methods: • _init__(self, diameter, height) takes in two parameters other than self, representing the diameter of the cylinder, and the height, and uses this information to set up self.r and self.h. Note that to get the radius (self.r) from the diameter, you'll need to divide by 2. • get_surface_area(self) returns the surface area of the cylinder, given by the formula: A = 2лr² + 2лrh You should import math and use math.pi to get an accurate value for get_volume (self) returns the volume of the cylinder, given by the formula: V = πr²harrow_forwardCreate a class called Employee that includes three pieces of information as instance variables—a first name (typeString), a last name (typeString) and a monthly salary (double).Provide a set and a get method for each instance variable.Keep in mind you should get values from user.There should be a method called calculateSalary() witch deducts the income tax from the salary on the following basis: 20% income tax if the salary is above Rs 30000. 15% income tax if the salary is between Rs.20000 and Rs.30000. 10% income tax if the salary is below Rs. 20000. Write a test application named EmployeeTest that demonstrates class Employee’s capabilities. Create Employee objects and display each object’s full name ,salary , income tax and net salary of employees. note.....This is java programmmarrow_forwardCreate a class called Employee that includes three pieces of information as instance variables—a first name (typeString), a last name (typeString) and a monthly salary (double).Provide a set and a get method for each instance variable.Keep in mind you should get values from user.There should be a method called calculateSalary() witch deducts the income tax from the salary on the following basis: 20% income tax if the salary is above Rs 30000. 15% income tax if the salary is between Rs.20000 and Rs.30000. 10% income tax if the salary is below Rs. 20000. Write a test application named EmployeeTest that demonstrates class Employee’s capabilities. Create Employee objects and display each object’s full name ,salary , income tax and net salary of employees.arrow_forward
- Write a class CountObject which has a method namenumberfoObjects() which returns the number of objects been created ofthat class. Also write a class that will create few objects of CountObjectclass and show the count. (Hint: you have to use static variable inCountObject class).arrow_forwardCreate a class called Invoice in your assignment source package. An Invoice should include four pieces of information as attributes(instance variables) - a part number of type String, a part description of type String, a purchasing quantity of type Int, and a price per item of type double. Your class should have a full constructor that initializes all the four attributes. Provide a set and a get method for each attribute. In addition, provide a method named getInvoiceTotal that calculates the invoice total, purchasing quantity * price per ite, and returns the invoice total. If the quantity is negative, returns 0. Create an test app named InvoiceTest in the same package that demonstrates class Invoice's capabilities.arrow_forwardCreate a RobotFriend class. RobotFriend is a new toy just on the market. Copy the starter class and the tester from Codecheck. A RobotFriend has a name and replies to various commands Provide a constructor that takes the name of the RobotFriend as a parameter. Remember that a constructor has the same name as the class. What does the class need to remember? That is the instance variable. Provide the following methods: public String getName() gets the name of this RobotFriend public void setName(String newName) sets a new name for this RobotFriend public String whatDoYouNeed() returns a string consisting of name + " needs a battery charge" where name is the name of this RobotFriend (which was supplied in the constructor) public String doCommand(String whatToDo) returns a string consisting of "Your friend " + name + " does not " + whatToDo where name is the name of this RobotFriend and whatToDo is the parameterarrow_forward
- write a class called OneItemBag ( OneItemBag.java ). This class represents a bag that can hold any single type of object (decided at bag-creation time), and only one item of that type at a time. You may have a zero-parameter constructor if you want one, but you must have the following three features:1. a method that puts an item in the bag (addItem()) which returns whether or not it was successfully added2. a method that removes an item from the bag and returns it (removeItem()), return null if there is no item3. a method to check if an item is in the bag (hasItem()) which returns true or falsearrow_forwardCreate a class with the name 'QuadraticSolver'.The two roots of a quadratic equation of the form ??2 + ?? + ? = 0 can be obtained using the quadratic equation formula ?2 − 4?? is called the discriminant of the quadratic equation. If it is positive, the equation has two real roots. If it is zero, the equation has one root. If it is negative, the equation has no real roots. In the QuadraticSolver main method, write a program that prompts the user to enter values for a, b, and c and displays the result based on the discriminant. If the discriminant is positive, display the two roots. If the discriminant is 0, display one root. Otherwise, display the imaginary roots. Note that you can use Math.pow(x, 0.5) to compute √?. Here are three separate sample runs: 1.0, 3, 1The equation has two roots: -0.38 and -2.62 1, 2.0, 1The equation has one root: -1.00 1, -4, 8The equation has two imaginary roots: 2.00 + 2.00i and 2.00 - 2.00iarrow_forwardCreate a class called Student to represent a Student exam grades. The class has four instance variables: A String variable for the name, and three double variables to store three exams grades for the student. 1. Write a mutator method that takes four parameters-A String and three doubles. Use these parameters to initialize the instance variables declared earlier. 2. Write a getAverage method that calculates and returns the average of the three exam grades. 3. Write a separate program that creates 2 Student objects to hold the following data. First Name Exam#1 Exam#2 Exam#3 Ahmed 83.0 95.5 90.0 Kareema 75.25 83.0 89.0 Output the name and average grade for each of the above students.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education