Concept explainers
Interaction with super class
Program plan:
- Create a class “Employee”,
- Define the method “getHours()” to return “40”.
- Define the method “getSalary()” to return “40000.0”.
- Define the method “getVacationDays()” to return “10”.
- Define the method “getVacationForm()” to return “yellow”.
- Create a class “Marketer” that extends the super class “Employee”,
- Define the method “advertise()” ,
- Print the string.
- Define the method “getSalary()”,
- Call the method “getSalary()” of super class and return the updated value.
- Define the method “main()”,
- Create object for “Marketer” class.
- Call the method “advertise()”.
- Print the value returned from “getsalary()”.
- Define the method “getSalary()”,
- Print the string.
- Define the method “advertise()” ,
This program demonstrates the class that accompanies the other law firm classes.
Explanation of Solution
Program:
File name: “Employee.java”
//Create a class
public class Employee
{
//Define the method
public int getHours()
{
//Retunr "40"
return 40;
}
//Define the method
public double getSalary()
{
//Return "40000.0"
return 40000.0;
}
//Define the method
public int getVacationDays()
{
//Return "10"
return 10;
}
//Define the method
public String getVacationForm ()
{
//Return "yellow"
return " yellow";
}
}
File name: “Marketer.java”
//Create a class
public class Marketer extends Employee
{
//Define the method advertise()
public static void advertise()
{
//Print the string
System.out.println("Act now, while supplies last!");
}
//Define the method
public double getSalary()
{
/*Call the method of super class and return the updated value*/
return super.getSalary() + 10000;
}
//Define the main() method
public static void main(String[] args)
{
//Create object
Marketer m=new Marketer();
//Call the method
m.advertise();
//Print the value returned from getSalary()
System.out.println("$"+m.getSalary());
}
}
Output:
Act now, while supplies last!
$50000.0
Want to see more full solutions like this?
Chapter 9 Solutions
MyProgrammingLab with Pearson eText -- Access Code Card -- for Building Java Programs
- Write a FancyCar class to support basic operations such as drive, add gas, honk horn, and start engine. FancyCar.java is provided with method stubs. Follow each step to gradually complete all methods. Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main() method includes basic method calls. Add statements in main() as methods are completed to support development mode testing. Step 0. Declare private fields for miles driven as shown on the odometer (int), gallons of gas in tank (double), miles per gallon or MPG (double), driving capacity (double), and car model (String). Note the provided final variable indicates the gas tank capacity of 14.0 gallons. Step 1 (2 pts). 1) Complete the default constructor by initializing the odometer to five miles, tank is full of gas, miles per gallon is 24.0, and the model is "Old Clunker". 2)…arrow_forwardFind the error: daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(7): daily_sales[i] = float(input('Enter the sales for ' \ + day_of_week[i] + ': ')arrow_forwardFind the error: daily_sales = [0.0, 0,0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(7): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': ')arrow_forward
- Find the error: daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(6): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': '))arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it and normalize it? Give two references with your answer.arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Consider that the database offline is not allowed since people are connected to it and personal data might be bridged and not secured. Provide three refernces with you answer.arrow_forward
- Should software manufacturers should be tolerant of the practice of software piracy in third-world countries to allow these countries an opportunity to move more quickly into the information age? Why or why not?arrow_forwardI would like to know about the features of Advanced Threat Protection (ATP), AMD-V, and domain name space (DNS).arrow_forwardPlease show the code for the Tikz figurearrow_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