![Building Java Programs: A Back To Basics Approach (5th Edition)](https://www.bartleby.com/isbn_cover_images/9780135471944/9780135471944_smallCoverImage.jpg)
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()” ,
![Check Mark](/static/check-mark.png)
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
Building Java Programs: A Back To Basics Approach (5th Edition)
- In the previous homework scenario problem below: You have been hired by TechCo to create and manage their employee training portal. Your first task is to develop a program that will create and track different training sessions in the portal. Each training session has the following properties: • A session ID (e.g., "TECH101", "TECH205") • A session title (e.g., "Machine learning", "Advanced Java Programming") • A total duration in hours (e.g., 5.0, 8.0) • Current number of participants (e.g., 25) Each session must have at least a session ID and a total duration and must met the following requirements: • The maximum participant for each session is 30. • The total duration of a session must not exceed 10 hours. • The current number of participants should never exceed the maximum number of participants. Design an object-oriented solution to create a data definition class(DDC) and an implementation class for the session object. In the DDC, a session class must include: • Constructors to…arrow_forwardSend me the lexer and parserarrow_forwardHere is my code please draw a transition diagram and nfa on paper public class Lexer { private static final char EOF = 0; private static final int BUFFER_SIZE = 10; private Parser yyparser; // parent parser object private java.io.Reader reader; // input stream public int lineno; // line number public int column; // column // Double buffering implementation private char[] buffer1; private char[] buffer2; private boolean usingBuffer1; private int currentPos; private int bufferLength; private boolean endReached; // Keywords private static final String[] keywords = { "int", "print", "if", "else", "while", "void" }; public Lexer(java.io.Reader reader, Parser yyparser) throws Exception { this.reader = reader; this.yyparser = yyparser; this.lineno = 1; this.column = 0; // Initialize double buffering buffer1 = new char[BUFFER_SIZE]; buffer2 = new char[BUFFER_SIZE]; usingBuffer1 = true; currentPos = 0; bufferLength = 0; endReached = false; // Initial buffer fill fillBuffer(); } private…arrow_forward
- Create 2 charts using this data. One without using wind speed and one including max speed in mph. Write a Report and a short report explaining your visualizations and design decisions. Include the following: Lead Story: Identify the key story or insight based on your visualizations. Shaffer’s 4C Framework: Describe how you applied Shaffer’s 4C principles in the design of your charts. External Data Integration: Explain the second data and how you integrated it with the Halloween dataset. Compare the two datasets. Attach screenshots of the two charts (Bar graph or Line graph) The Shaffer 4 C’s of Data Visualization Clear - easily seen; sharply defined• who's the audience? what's the message? clarity more important than aestheticsClean - thorough; complete; unadulterated, labels, axis, gridlines, formatting, right chart type, colorchoice, etc.Concise - brief but comprehensive. not minimalist but not verboseCaptivating - to attract and hold by beauty or excellence does it capture…arrow_forwardHow can I resolve the following issue?arrow_forwardI need help to resolve, thank you.arrow_forward
- Let the user choose encryption or decryption. For encryption, let user input the key in Hexadecimal number, the plain text in Hexadecimal number, output the ciphertext (in hexadecimal numbers). For decryption, let user input the key in Hexadecimal number, the ciphertext (in hexadecimal numbers), output the decrypted message (Hexadecimal number). Both encryption and decryption should output the different operation results for each round like the following: For example: Round 1: E(R0) = ...... (Hex or Binary) K1 = …… E(Ro) xor K1 = S-box outputs = …… f(Ro1, K1) = ….. L2 =R1 =……. La = Ra Round 2: .....• No Encryption/Decryption libraries or functions provided by the third party are allowed. Submit your program codes to Moodle with the notes of how to compile and run your program.arrow_forwardWhen the given integer variable numberOfPackages is: greater than 12, output "Needs more than one box". between 5 inclusive and 12 inclusive, output "Large box". between 0 exclusive and 4 inclusive, output "Small box". less than or equal to 0, output "Invalid input". End with a newline.arrow_forwardsummarize in a short paragraph how to Advance Incident Response and Automation in ML home based security systemsarrow_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
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)