Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 1, Problem 33E
Write the header for a method named send that has one parameter of type String, and does not return a value.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these 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…
This 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”);
Write the header for a method named send that has one parameter of type String, and does not return a value.
Chapter 1 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 1 - Prob. 1ECh. 1 - Prob. 2ECh. 1 - Prob. 3ECh. 1 - Prob. 4ECh. 1 - This is a very simple example, and not many colors...Ch. 1 - Prob. 6ECh. 1 - Prob. 7ECh. 1 - Prob. 8ECh. 1 - Prob. 9ECh. 1 - Select Show Terminal from the View menu. This...
Ch. 1 - Select Show Code Pad from the View menu. This...Ch. 1 - Prob. 12ECh. 1 - Prob. 13ECh. 1 - Prob. 14ECh. 1 - Look at the pop-up menu of class Picture again....Ch. 1 - In the source code of class Picture, find the part...Ch. 1 - Add a second sun to the picture. To do this, pay...Ch. 1 - Prob. 18ECh. 1 - Prob. 19ECh. 1 - Prob. 20ECh. 1 - Create an object of class Student. You will notice...Ch. 1 - Prob. 22ECh. 1 - Prob. 23ECh. 1 - Call the numberOfStudents method of that class....Ch. 1 - Look at the signature of the enrollStudent method....Ch. 1 - Prob. 26ECh. 1 - Prob. 27ECh. 1 - Prob. 28ECh. 1 - Prob. 29ECh. 1 - In this chapter we have mentioned the data types...Ch. 1 - What are the types of the following values?...Ch. 1 - Prob. 32ECh. 1 - Write the header for a method named send that has...Ch. 1 - Prob. 34ECh. 1 - Prob. 35ECh. 1 - Prob. 36E
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
Could errors have occurred in a byte from Question 1 without your knowing it? Explain your answer.
Computer Science: An Overview (12th Edition)
Revise the definition of the class ListNode in Listing 12.4 so that it uses a type parameter instead of the typ...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
Write a complete Java program that reads in a line of keyboard input containing two values of type int (separat...
Absolute Java (6th Edition)
Word Separator Write a program that accepts as input a sentence in which all of the words are run together, but...
Starting Out with C++: Early Objects
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Class: DoubleMethod Write a method using the header below public static double readDouble(String prompt) that displays the prompt string, followed by a space, then reads a floating-point number from the user, and returns it. Here is a typical usage: salary = readDouble("Please enter your salary:");percentageRaise = readDouble("What percentage raise would you like?");Write a test program to test the method.arrow_forwarduse only C# programming Write a method call CubeIt(int x, ref int cube) that takes two arguments and does not return a value. The method will cube the first argument and assign it to the second argument.In your main, call this method twice and print the value of the parameters after each method call. Write a method with the following header: static void CalculateTuitionFee(int numberOfCourses, double costPerCourse, ref double fees). This method will calculate and assign the required fees amount to the third argument. [Fees = number of courses * cost per course + 15.25].From your program Main() method, call the CalculateTuitionFee () method four times supplying different arguments each time and display the value of the third argument after each method call. Write a method that takes four parameter of type int. The method will assign the sum of the first two arguments to the third and the difference of the first two to the fourth. This method should be coded so that the calling…arrow_forwardWrite a method that will have a C++ string passed to it. The string will be an email address and the method will return a bool to indicate that the email address is valid. Email Validation Rules: ( These rules are not official.) No whitespace allowed 1 and only 1 @ symbol Must not start with the @ symbol At least 1 period after the @ symbol. Must not start with a period after the @ symbol Program will prompt for an email address and report if it is valid or not according to the rules posted above. The program will loop and prompt me to continue.arrow_forward
- Value-returning methods must pass parameters. -True or -Falsearrow_forwardC++ program Write a program that will include a method for encrypting a string and a method to decrypt a string. An "encrypted" string is a string that has been altered based on a formula so it is no longer understandable. This string can also be "decrypted" to return the value of the original string. This program needs to have 3 methods - main(), a method to encrypt a passed string and return the generated results, a method to decrypt a generated string an return the results. The encrypt and decrypt methods must be value methods that return results. No display related code is expected in these methods. Do not use c-strings/char arrays in the assignment. Use the String class as described in section 10.7. ************************* To encrypt a string, Add 1 to each character of the string. Thus 'A' becomes 'B', "X" becomes "Y", etc. To decrypt a string, reduce it's value by 1. string myWord = "Hello World!";string encryptedWord = myWord; // sets the same sizeFor each char - loop…arrow_forwardIN JAVA Write a method (also known as functions in C++) named isPerfect that takes in one parameter named number, and return a String (the method's return type MUST BE a String) containing the factors for the number that totals up to the number if the number is a perfect number. If the number is not a perfect number, have the method return a null string (do this with a simple: return null; statement). Utilize this isPerfect method in a program that prompts the user for a maximum integer, so the program can display all perfect numbers from 2 to the maximum integer (be careful having the user pick a maximum integer bigger than 100000). Output: Enter the largest number to try to display: 100 6 is perfect: Factors: 1 2 3 28 is perfect: Factors: 1 2 4 7 14arrow_forward
- calcProduct is a value-returning method that calculates the product of two integer values sent to the function. Which statement represents a correct way of calling this method? O a. value = calcProduct (numl, num2); O b. calcProduct (numl, num2); O c. calcProduct (int num1, int num2); O d. value = calcProduct (int num1, int num2):arrow_forwardProgram62.javaWrite a program that prompts for a full name (first and last) and assigns it to one string. The program then passes the full name to a void method as its sole parameter. The void method should print the first name, on one line, as many times as indicated by the length of the last name. Sample Output (image below) Program64.javaWrite a program that demonstrates method overloading by defining and calling methods that return the area of a triangle, a rectangle, or a square.arrow_forwardQ1. Create a method that transforms a time given in seconds to a String that shows the hours, minutes, and seconds like the time on a digital clock. The String returned from the method shows the time as hours:minutes:seconds. Use the following header: public static String convertTime(int totalSeconds) Write a test program that asks the user for the time in second then displays the time in hours:minutes:seconds. Hint: Use the / operator to get the number of minutes, and the % operator to get the number of seconds left over. Sample runs Enter time in seconds: 150 0:2:30 Enter time in seconds: 2533 0:42:13 Enter time in seconds: 15463 4:17:43arrow_forward
- True or False? Arrays cannot be passed as parameters, but must be used only in the main method.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_forwardComputer Science Write a Java program that calls a method from main and passes it two integer parameters called minValue and maxValue. The method should prompt the user to enter a number within the range of minValue and maxValue (inclusive), until the user provides a valid input. The method should return the value provided by the user, and the program should display what the user entered after the method is called.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY