Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 7PP
Program Plan Intro
To write a program to state True or false for every constructor method and to test the following temperature equalities:
0.0 degrees C = 32.0 degrees F
-40.0 degrees C = -40.0 degrees F
100.0 degrees C = 212.0 degrees F
Program Plan:
Write a program in Java to state true or false for every constructor method and to test the temperature equalities.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Design a LandTract class that has two fields (i.e. instance variables): one for the tract’s length(a double), and one for the width (a double). The class should have:
a constructor that accepts arguments for the two fields
a method that returns the tract’s area(i.e. length * width)
an equals method that accepts a LandTract object as an argument. If the argument object
holds the same data (i.e. length and width) as the calling object, this method should return
true. Otherwise, it should return false.
a toString method (that returns a String representation of the tract’s length, width, and
area).
Demonstrate the class in a program by creating an array of three LandTract objects initialized with user input. Then, print the info of the LandTract objects stored in the array by invoking the toString method (implicitly or explicity). Also, use the equals method to compare at least two LandTract objects and print wether they are of equal size or not.
Sample Output:…
PYTHON:
Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise.
Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values.
Ex: If the input is:
Pablo Picasso 1881 1973 Three Musicians 1921
the output is:
Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921
If the input is:
Brice Marden 1938 -1 Distant Muses 2000
the output is:
Artist: Brice Marden, born 1938 Title: Distant Muses, 2000
I have the code but I am getting errors that I can't seem to get rid of any suggestions would be appreciated
Create an Employee Class that will have
Two instance variable: name and workingPeriod
A class method named employeeByJoiningYear():
• To create an Employee object by joining year for calculating the working
period
o it will have two Parameter name and year
• A static method experienceCheck() to check if an Employee is experienced or not
o It will take working period and gender as parameter
o If an employee's working period is less than 3, he or she is not experienced
[You are not allowed to change the code below]
# Write your code here
employee1 = Employee('Dororo', 3)
employee2 = Employee.employeeByJoiningYear('Harry', 2016) 6
print(employee1.workingPeriod)
print(employee2.workingPeriod)
print(employee1.name)
print(employee2.name)
print(Employee.experienceCheck(2, "male"))
print(Employee.experienceCheck(3, "female"))
Оutput
3
Dororo
Harry
He is not experienced
She is experienced
Chapter 4 Solutions
Absolute Java (6th Edition)
Ch. 4 - Write a method called makeItNewYears that could be...Ch. 4 - Write a method called yellIfNewYear that could be...Ch. 4 - Prob. 3STECh. 4 - Write a method called happyGreeting that could be...Ch. 4 - Prob. 5STECh. 4 - Write a method called advanceYear that could be...Ch. 4 - Prob. 7STECh. 4 - Prob. 8STECh. 4 - Consider the definition of the method monthString...Ch. 4 - The method writeOutput in Display 4.2 uses the...
Ch. 4 - Rewrite the definitions of the methods getDay and...Ch. 4 - Rewrite the method getMonth in Display 4.2 using...Ch. 4 - In the definition of precedes in Display 4.7, we...Ch. 4 - Prob. 14STECh. 4 - Following the style guidelines given in this book,...Ch. 4 - Prob. 16STECh. 4 - List all the accessor methods in the class...Ch. 4 - List all the mutator methods in the class...Ch. 4 - Write a better version of the method dateOK with...Ch. 4 - What is the signature of each of the following...Ch. 4 - Prob. 21STECh. 4 - Prob. 22STECh. 4 - Prob. 23STECh. 4 - If a class is named CoolClass, what names are...Ch. 4 - Suppose you have defined a class such as the...Ch. 4 - What is a no-argument constructor? Does every...Ch. 4 - What would be the last line in the dialogue in...Ch. 4 - What would be the last line in the dialogue in...Ch. 4 - Write a program that outputs a certain coded...Ch. 4 - Prob. 2PPCh. 4 - Define a class called Journal that could be used...Ch. 4 - Define a class called WordCount whose objects...Ch. 4 - Write a grading program for a class with the...Ch. 4 - Prob. 7PPCh. 4 - Redefine the class Date in Display 4.13 so that...Ch. 4 - Define a class whose objects are records on animal...Ch. 4 - Prob. 10PPCh. 4 - Prob. 11PPCh. 4 - This programming project extends Programming...Ch. 4 - Your Community Supported Agriculture (CSA) farm...Ch. 4 - A comma-separated values (CSV) file is a simple...Ch. 4 - Prob. 15PP
Knowledge Booster
Similar questions
- Create an Employee Class that will have ● Two instance variable: name and workingPeriod ● A class method named employeeByJoiningYear(): o To create an Employee object by joining year for calculating the working period o It will have two Parameter name and year ● A static method experienceCheck() to check if an Employee is experienced or not o It will take working period and gender as parameter o If an employee’s working period is less than 3, he or she is not experienced [You are not allowed to change the code below] # Write your code here employee1 = Employee('Dororo', 3) employee2 = Employee.employeeByJoiningYear('Harry', 2016) print(employee1.workingPeriod) print(employee2.workingPeriod) print(employee1.name) print(employee2.name) print(Employee.experienceCheck(2, "male")) print(Employee.experienceCheck(3, "female")) Output 3 5 Dororo Harry He is not experienced She is experiencedarrow_forwardDefine the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwisearrow_forwardObject Oriented Programming in JAVA Define and use a class for the student record. The class should have instance variables for the quizzes, midterm, final, overall numeric score for the course, and final letter grade. The overall numeric score is a number in the range 0 to 100, which represents the weighted average of the student’s work. The class should have methods to compute the overall numeric grade and the final letter grade. These last methods should be void methods that set the appropriate instance variables. Your class should have a reasonable set of accessor and mutator methods, an equals method, and a toString method.arrow_forward
- Assignment:The BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdarrow_forwardPython Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise. Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values. Ex: If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921 If the input is: Brice Marden 1938 -1 Distant Muses 2000 the output is: Artist: Brice Marden, born 1938 Title: Distant Muses, 2000arrow_forwardthis is question number 2i need answer within 6 or 7 hoursarrow_forward
- The Essay class has a default constructor, a constructor with two parameters, and a constructor with three parameters. Declare the following objects: essay1 with no arguments essay2 with essayTitle and essayAuthor as arguments essay3 with essayTitle, essayAuthor, and essayYear as arguments Ex: If the input is Painting Cole 1919, then the output is: Essay: Undefined, Unspecified, 0 Essay: Painting, Cole, 0 Essay: Painting, Cole, 1919 Archive.java public class Archive { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); StringessayTitle; StringessayAuthor; intessayYear; essayTitle=scnr.next(); essayAuthor=scnr.next(); essayYear=scnr.nextInt(); /* Your code goes here */ essay1.print(); essay2.print(); essay3.print(); } } Essay.java public class Essay { private String title; private String author; private int year; public Essay() { // Default constructor title = "Undefined"; author = "Unspecified"; year = 0; }…arrow_forwardCode the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledarrow_forwardPart C: Write Java Code for the following case scenarios: Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX-L, where each X is a digit within the range 0-9 and the L is a letter within the range A_M. Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: Shift (an integer) Hourly pay rate (double) The workday is divided into two shifts: day and night. The shift field will be an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstarte the classes by writing a program that uses a ProductionWorker object. In a particular…arrow_forward
- Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise. Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values. Ex: If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921 If the input is: Brice Marden 1938 -1 Distant Muses 2000 the output is: Artist: Brice Marden, born 1938 Title: Distant Muses, 2000 Here is the original code: class Artist:# TODO: Define constructor with parameters to initialize instance attributes#…arrow_forwardDefine the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise. Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values. Ex: If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921 If the input is: Brice Marden 1938 -1 Distant Muses 2000 the output is: Artist: Brice Marden, born 1938 Title: Distant Muses, 2000 code used: class Artist: # TODO: Define constructor with parameters to initialize instance attributes #…arrow_forwardJava - Constructors Create a class named Book that has the following attributes: Publisher - String Year Published - Integer Price - Double Title - String Create a constructor for the class Book that has the parameters from the attributes of the class. After, create a method for the class that displays all attributes. Ask the user for inputs for the attributes and use the constructor to create the object. Lastly, print the values of the attributes. Inputs 1. Publisher 2. Year Published 3. Price 4. Book Title XYZ Publishing 2020 1000.00 How to Win? Sample Output Published: ABC Publishing Year Published: 2022 Price: 150.00 Book Title: Stooping too low Stooping too low is published by ABC Publishing on 2022. It sells at the price of Php150.00.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT