EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 1PE
Program Plan Intro
Overloading the method
Filename: “FormLetterWriter.java”
- Define the “FormLetterWriter” class
- Define the main method.
- Call the “displaySalutation” method with single parameter.
- Call the “displayLetter” method.
- Call the “displaySalutation” method with two parameters.
- Call the method “displayLetter”.
- Define the “displaySalutation” method
- Display the “Dear Mr. or Ms.” followed by last name.
- Define the “displaySalutation” method
- Display the first name followed by last name.
- Define the “displayLetter” method
- Display the statement.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
For your homework assignment, build a simple application for use by a local retail store. Your program should have the following classes: Item: Represents an item a customer might buy at the store. It should have two attributes: a String for the item description and a float for the price. This class should also override the __str__ method in a nicely formatted way. Customer: Represents a customer at the store. It should have three attributes: a String for the customer's name, a Boolean for the customer's preferred status, and a list of 5 indexes to hold Item objects. Include the following methods: make_purchase: accepts a String and a double as parameters to represent the name and price of an item this customer is purchasing. Create a new Item object with this info and append it to the internal list. If the customer is a preferred customer based on the Boolean attribute's value, take 10% off the total sale price. __str__: Override this method to print the customer's name and every…
This code is in java.
Transportation Program
Main file called transportation. It will create the sedan and coupe objects.
You will pass in parameters for the number of exterior and interior color options.
It will print a message from the car class that prints
All cars have Wheels: #of wheels. ; Interior Color Options: # of interior colors ; Exterior Color Options: # of colors.
A message from the sedan and the coupe classes that print the number of doors and cylinders.
The car class is the parent class. It will have a constructor for the number of wheels (4), exterior colors (5), and interior colors (2).
It will also have a method that prints the text.
The sedan and coupe classes will be children classes to the car class.
They will have a constructor that calls the car’s constructor and adds in variables for the number of doors and number of cylinders.
sedans have 4 doors and 6 cylinder engines.
coupes have 2 doors and 4 cylinder engines.
The sedan and coupe classes will…
Create a class named Commission that includes three variables:
a double sales figure, a double commission rate, and an int
commission rate. Create two overloaded methods named
computeCommission(). The first method takes two double
parameters representing sales and rate, multiplies them, and then
displays the results. The second method takes two parameters: a
double sales figure and an integer commission rate. This method
must divide the commission rate figure by 100.0 before multiplying
by the sales figure and displaying the commission. Supply
appropriate values for the variables, and write a main() method
method. Save the file
that tests each overloaded
as
Commission.java.
Chapter 4 Solutions
EBK JAVA PROGRAMMING
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - Prob. 6RQCh. 4 - Prob. 7RQCh. 4 - Prob. 8RQCh. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - Prob. 17RQCh. 4 - Prob. 18RQCh. 4 - Prob. 19RQCh. 4 - Prob. 20RQCh. 4 - Prob. 1PECh. 4 - Prob. 2PECh. 4 - Prob. 3PECh. 4 - Prob. 4PECh. 4 - Prob. 5PECh. 4 - Prob. 6PECh. 4 - Prob. 7PECh. 4 - Prob. 8PECh. 4 - Prob. 9PECh. 4 - Prob. 10PECh. 4 - Prob. 11PECh. 4 - Prob. 1GZCh. 4 - Prob. 2GZ
Knowledge Booster
Similar questions
- In python Add the following four methods to your Crew class: move(self, location): This takes in a location as a string, along with self, and attempts to move the crew member to the specified location. If location is one of the five valid location options ("Bridge", "Medbay", "Engine", "Lasers", or "Sleep Pods"), then this should change self.location to that new value. Otherwise, the function should print out the message: Not a valid location. repair(self, ship): first_aid(self, ship): fire_lasers(self, ship, target_ship, target_location): The above three methods represent tasks that a basic Crew member is not capable of (but one of its derived classes will be able to accomplish). So each of them should simply print out a message of the form: <Name> doesn't know how to do that. Examples: Copy the following if __name__ == "__main__" block into your hw12.py file, and comment out tests for parts of the class you haven’t implemented yet. if __name__ == '__main__': crew1…arrow_forwardmau Open Leathing inta... - The class has data members that can hold the name of your cube, length of one of the sides and the color of your cube. - The class has a constructor that accepts the name, length of one of the sides, and color as arguments and sets the data members to those values. - The class has the following methods to set the corresponding data member. setName(string newName) setSide(double newSide) setColor(string newColor) - The class has a method called getVolume() that returns the volume of the cube, calculated by cubing the length of the side. - The class has a method called volumelncrease(double newVolume) that receive the percent the volume should increase, and then the side to the corresponding value. i - For example, 2.5 indicates 2.5% increasing of the volume. So you take the current volume, increase it by 2.5%, and then find the cube root to calculate the new side length. You can use the built in function called cbrt, part of the math library, to find the cube…arrow_forwardWrite the C# application SwimmingWaterTemperature containing a variable that can hold a temperature expressed in degrees Fahrenheit. Within the class, create a method that accepts a parameter for a water temperature and returns true or false, indicating whether the water temperature is between 70 and 85 degrees and thus comfortable for swimming. If the temperature is not between 32 and 212 (the freezing and boiling points of water), it is invalid, and the method should throw an ArgumentException. In the Main() method, continuously prompt the user for data temperature, pass it to the method, and then display the following messages indicating whether the temperature is comfortable, not comfortable, or invalid: X degrees is comfortable for swimming. X degrees is not comfortable for swimming. Value does not fall within the expected range. Enter the value 999 to quit the program. using System; using static System.Console; class SwimmingWaterTemperature { static void Main() {…arrow_forward
- This code is in java. Transportation Program Main file called transportation. It will create the sedan and coupe objects. These will be in sedan.java and coupe.java. You will pass in parameters for the number of exterior and interior color options. It will print a message from the car class that prints All cars have Wheels: #of wheels. ; Interior Color Options: # of interior colors ; Exterior Color Options: # of colors. A message from the sedan and the coupe classes that print the number of doors and cylinders. The car class is the parent class. It will have a constructor for the number of wheels (4), exterior colors (5), and interior colors (2). It will also have a method that prints the text. The sedan and coupe classes will be children classes to the car class. They will have a constructor that calls the car’s constructor and adds in variables for the number of doors and number of cylinders. sedans have 4 doors and 6 cylinder engines. coupes have 2 doors and 4 cylinder…arrow_forwardWrite a class named Employee that has the following fields: name: The name field is a String object that holds the employee's name. idNumber: The idNumber is an integer variable that holds the employee's ID number. department: The department field is a String object that holds the name of the department where the employee works. position: The position field is a String object that holds the employee's job title. Write mutator methods that store values in these fields and accessor methods that return the values in these fields. Once you have written the class, write a separate program that creates three Employee objects to hold the following data. Name ID Number Azah Samsudin Mira Kamal Che Yah Sam Department Computer Science Biomedical Language Position Programmer Researcher Lecturer 11011 35125 80001 The program should store the data in the three objects and then display the data for each employee on the screen.arrow_forwardYou will create a couple of classes that could be used to create a Text Adventure game. The class will be called "Item" and will represent an item in the game that can be carried and used by a player (such as a weapon or a tool). The Item Class The Item class will have only one property: A string description. The Item class will have exactly 3 methods: There will be a default constructor that takes no parameters. This constructor will give a generic, default description of the Item. There will be a constructor that takes a string parameter, and it will initialize the Item's description based on the parameter. There will be a method called "print" that will print the Item's description to standard output. PLEASE MAKE SURE ITS POSSIBLE TO COMPILE WITH THIS CODE. THANKS. #include "Item.h" #include <iostream> #include <string> using namespace std; int main() { Item sword("Sword of Destiny"); Item potion("Healing Potion"); Item key("Key of Wisdom"); string name; cout…arrow_forward
- ● Create a class named Decimals. Write a static method named printDecimalDigits that takes a double as a parameter and does not return anything. ● ● ● The method should print out "Digits after decimal point: ", followed by all the digits after the decimal point on one line (do not include the decimal point). Additional rule: Your code must not contain any loops. Create a test class named DecimalsTest that contains the main method and use the sample usage below to check your code. Method Call Decimals.print DecimalDigits (37.2) Decimals.print DecimalDigits (1000) Method Output Digits after decimal point: 2 Digits after decimal point: 0 Decimals.printDecimalDigits (18.3927493038) Digits after decimal point: 3927493038arrow_forwardIn C#, Create a program named ConferencesDemo for a hotel that hosts business conferences. Allows a user to enter data about five Conference objects and then displays them in order of attendance from smallest to largest. The Conference class contains fields for the following: group - The group name (as a string) date - The starting date (as a string) attendees - The number of attendees (as an int) Include properties for each field. Also, include an IComparable.CompareTo() method so that Conference objects can be sorted in order from least to greatest attendees.arrow_forwardCreate a class IndependenceUSA and write code which asks the user to enter text that contains the American Independence day ( July 4th 1776). Read the date using the method next() 3 times. The user should enter the Independence day in the order month, day, year as shown in the first two runs below( we are not case sensitive) . Use the String method compareToIgnoreCase() to test the validi-ty of the date and print “Hurrah!” if the date entered is correct, or “No, no , no! Incorrect!” if the date incorrect is incorrect, or of the date entered in the wrong order. In other words, you compare your input to “July” , “4”, “1776” , in that order and you don't case for capital or small case letters.arrow_forward
- I need this assignment done in java with screenshots of it running.arrow_forwardThis C# program assignment requires that you write and call two programmer defined methods as described below: Method #1 (MyAddress) – this programmer defined method should output your name and address in a mailing label format. This method does not require any parameters, and will not return any value. Method #2 (AddressOut) – this programmer defined method should have three string parameters (name, address, and city‐state‐zip) and should output the passed parameters in mailing label format. This method will not return any value. Your Main() method for this program should consist of two lines of code – calls to each of the methods. Here is an example of the code in my Main() method MyAddress(); AddressOut(“Tim Jones”, “123 Main St.”, “East Brunswick, NJ 08816”);arrow_forwardjavaaa Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the number of vowels in the string, and another method that returns the number of consonants in the string. Demonstrate the class in a program by invoking the methods that return the number of vowels and consonants. Print the counts returned. Imagine you are developing a software package for an online shopping site that requires users to enter their own passwords. Your software requires that users’ passwords meet the following criteria: The password should be at least six characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. Write a program that asks the user to enter a password, then displays a message indicating whether it is valid or not.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage