Java How to Program, Early Objects (11th Global Edition)
11th Edition
ISBN: 9780134751856
Author: Harvey Deitel, Paul J. Deitel
Publisher: Pearson Global Edition
expand_more
expand_more
format_list_bulleted
Question
Chapter 3, Problem 10.1E
Program Plan Intro
Date Class
Program Plan:
- Define a class called Date.
- Declare three private variables of type int to hold month, day and year.
- Define a default constructor that sets the instance variables to the default values.
- Define a constructor to initialize the class variables with parameter values.
- Define set and get methods for each instance variables.
- Define a method called displayDate() to display the date in the form of month/day/year.
- Define a class called DateTest.
- Define the main method.
- Define a Date object by using parameterized constructor.
- Call the displayDate() method by using Date object to display the date.
- Define another Date object by using default constructor.
- Prompt the user for month, day and year.
- By using the set methods, set the month, day and year for the object.
- By using get methods, display the month, day and year values in different formats.
- Call the displayDate() method by using Date object to display the date.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Roll no. 021
Java language
Give solution
#pyhton programing
topic: Introduction to Method and Designing class
Method overloading & Constructor overloading
------------------
please find the attached image
State whether it is true or false and why .
Chapter 3 Solutions
Java How to Program, Early Objects (11th Global Edition)
Ch. 3 - Fill in the blanks in each of the following: Each...Ch. 3 - Fill in the blanks in each of the following:...Ch. 3 - Fill in the blanks in each of the following:...Ch. 3 - Fill in the blanks in each of the following: Each...Ch. 3 - Prob. 1.5SRECh. 3 - Fill in the blanks in each of the following: Java...Ch. 3 - Prob. 1.7SRECh. 3 - Prob. 1.8SRECh. 3 - Prob. 1.9SRECh. 3 - Prob. 1.10SRE
Ch. 3 - Prob. 1.11SRECh. 3 - Prob. 1.12SRECh. 3 - Fill in the blanks in each of the following: A(n)...Ch. 3 - Prob. 1.14SRECh. 3 - Prob. 1.15SRECh. 3 - Prob. 1.16SRECh. 3 - Fill in the blanks in each of the following: Types...Ch. 3 - Prob. 2.1SRECh. 3 - Prob. 2.2SRECh. 3 - State whether each of the following is true or...Ch. 3 - Prob. 2.4SRECh. 3 - Prob. 2.5SRECh. 3 - Prob. 2.6SRECh. 3 - State whether each of the following is true or...Ch. 3 - State whether each of the following is true or...Ch. 3 - Prob. 2.9SRECh. 3 - Prob. 2.10SRECh. 3 - State whether each of the following is true or...Ch. 3 - Prob. 3.1SRECh. 3 - Prob. 4.1SRECh. 3 - (Keyword new) Whats the purpose of keyword new?...Ch. 3 - Prob. 2.1ECh. 3 - (Instance Variables) Explain the purpose of an...Ch. 3 - Prob. 4.1ECh. 3 - (Using a Class without Importing It) Explain how a...Ch. 3 - (set and get Methods) Explain why a class might...Ch. 3 - Prob. 7.1ECh. 3 - (Invoice Class) Create a class called Invoice that...Ch. 3 - (Employee Class) Create a class called Employee...Ch. 3 - Prob. 10.1ECh. 3 - (Target-Heart-Rate Calculator) While exercising,...Ch. 3 - (Computerization of Health Records) A health-care...
Knowledge Booster
Similar questions
- : A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, pointType, that can store and process a point in the x-y plane. You should then perform operations on the point, such as showing the point, setting the coordinates of the point, printing the coordinates of the point, returning the x-coordinate, and returning the y-coordinate. Also, write a test program to test the various operations on the point.arrow_forwardPlease help me with this Java chapter 6 programming challenge. Thank youarrow_forwarduse java to answerand Thank youarrow_forward
- Make C# (Sharp): console project named MyPlayList. Create an Album class with 4 fields to keep track of title, artist, genre, and copies sold. Each field should have a get/set property. Your Album class should have a constructor to initialize the title (other 3 variables should default to null or 0). In addition, create a public method in the Album class to calculate amount sold for the album (copies sold * cost_of_album). You determine the cost of each album. Also create a method in the Album class to display the information. Print out of information should look something like this: The album Tattoo You by the Rolling Stones, a Rock group, made $25,000,000. In the main method, create 3 instances of the Album class with different albums, use setters to set values of the artist, genre, and copies sold. And then use getters to display information about each on the console.arrow_forwardNote: It`s python codingarrow_forwardJava programarrow_forward
- Ag 1- Random Prime Generator Add a new method to the Primes class called genRandPrime. It should take as input two int values: 1owerBound and upperBound. It should return a random prime number in between TowerBound (inclusive) and upperBound (exclusive) values. Test the functionality inside the main method. Implementation steps: a) Start by adding the method header. Remember to start with public static keywords, then the return type, method name, formal parameter list in parenthesis, and open brace. The return type will be int. We will have two formal parameters, so separate those by a comma. b) Now, add the method body code that generates a random prime number in the specified range. The simplest way to do this is to just keep trying different random numbers in the range, until we get one that is a prime. So, generate a random int using: int randNum = lowerBound + gen.nextInt(upperBound); Then enter put a while loop that will keep going while randNum is not a prime number - you can…arrow_forwardIndicate whether the statement is true or false. 13. The non-static methods of a class are called instance method. 14. A constructor has no type and is therefore a void method. 15. A class can have only two constructors. 16. In shallow copying, each reference variable refers to its own object. 21. The method finalize automatically executes when the class objects goes out of scope. 22. A mutator method of a class changes the values of data members of the class. 23. In java, the reference this is used to refer to only the methods, not the instance variables of a class. 24. Classes that are defined within other classes are called inside classes. 25. Modifiers are used to alter the behavior of the class 26. A constructor has the same name as the class. 27. Constructors are called like any other method. 28. You can perform some arithmetic operations on class objects.arrow_forwardObject Oriented Programming: 213COMP, 214COMP (Feb-2022) Assignment- I [10 marks] Academic honesty: O Only pdf file accepted & student ID, will be your upload file. O Student who submit copied work will obtain a mark of zero. O Late work or attach file by email message not allowed. Q1: Write the signature for a method that has one parameter of type String, and does not return a value. Q2: Write the signature for a method that has two parameters, both of type Student, and returns an int value. Q3: Write the constructor's headers of the followings? new Student (202101156, “Ahmed"); new Address(51, "jazan university","CS&IT" ); new Grade(true, 505235600, 4.5); Q4: a) Write a class Student that define the following information: name, stid , age. b) Explain a mutators (setters) and accessors(getters) methods for each attributes(fields). c) Add three constructors: • with empty constructor. one parameter constructor (name of student) two parameters constructor (name and stid) d) Create two…arrow_forward
- Java - Access Specifiers Create a class named Circle that has attributes radius, area, and circumference and make the attributes private. Make a public method that sets the radius and a method that prints all attributes. Ask the user input for radius. Note: Use the PI from the math functions Inputs A line containing an integer 10 Sample Output Radius: 20 Area: 1256.64 Circumference: 125.66arrow_forward2. Import Classa) Implement a class Rectangle with two attributes, width and height. b) Implement an init method with an optional parameter type. Set the default value of the attributes of width and height to 1.c) Implement a display method to print the values of width and height.d) Implement a setWidth method to assign width to the instance variable.e) Implement a setHeight method to assign height to the instance variable.f) Implement a getWidth method to return the value of the instance variable width.g) Implement a getHeight method to return the value of the instance variable height.h) Implement an area method to return the value of area of a rectangle.i) Save Rectangle class as rectangle.py.j) Import Rectangle class from rectangle.py.k) Employs the Rectangle class methods above to set and get various measurements of a rectangle. 1) Instantiate two objects of type rectangle, one with arguments one without. r1 = Rectangle(4, 5)r2 = Rectangle() 2) Call display() to print width and…arrow_forwardNote: It`s python codingarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT