Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 9, Problem 7MC
Program Description Answer
Method that accepts value and return string representation of the value:
The method “ValueOf” is overloaded version of the string class that is used for accepting values of any primitive data types and will return the string representation of the value that is passed.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
If you write this method for a class, Java will automatically call it any time you concatenate an object of the class with a string.a. toStringb. plusStringc. stringConvertd. concatString
C# Write a method that accepts a string as an argument and displaysits contents backward. For instance, if the string argument is"gravity" , the method should display "ytivarg"
Vowels and Consonants Create an application with a method that accepts a string as an argument and returns the number of vowels that the string contains. The application should have another method that accepts a string as an argument and returns the number of consonants that the string contains. The application should let the user enter a string, and should display the number of vowels and the number of consonants it contains.
Chapter 9 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Write an if statement that displays the word digit...Ch. 9.2 - Prob. 9.3CPCh. 9.2 - Write a loop that asks the user, Do you want to...Ch. 9.2 - Prob. 9.5CPCh. 9.2 - Write a loop that counts the number of uppercase...Ch. 9.3 - Prob. 9.7CPCh. 9.3 - Modify the method you wrote for Checkpoint 9.7 so...Ch. 9.3 - Look at the following declaration: String cafeName...Ch. 9.3 - Prob. 9.10CP
Ch. 9.3 - Prob. 9.11CPCh. 9.3 - Prob. 9.12CPCh. 9.3 - Prob. 9.13CPCh. 9.3 - Look at the following code: String str1 = To be,...Ch. 9.3 - Prob. 9.15CPCh. 9.3 - Assume that a program has the following...Ch. 9.4 - Prob. 9.17CPCh. 9.4 - Prob. 9.18CPCh. 9.4 - Prob. 9.19CPCh. 9.4 - Prob. 9.20CPCh. 9.4 - Prob. 9.21CPCh. 9.4 - Prob. 9.22CPCh. 9.4 - Prob. 9.23CPCh. 9.4 - Prob. 9.24CPCh. 9.5 - Prob. 9.25CPCh. 9.5 - Prob. 9.26CPCh. 9.5 - Look at the following string:...Ch. 9.5 - Prob. 9.28CPCh. 9.6 - Write a statement that converts the following...Ch. 9.6 - Prob. 9.30CPCh. 9.6 - Prob. 9.31CPCh. 9 - The isDigit, isLetter, and isLetterOrDigit methods...Ch. 9 - Prob. 2MCCh. 9 - The startsWith, endsWith, and regionMatches...Ch. 9 - The indexOf and lastIndexOf methods are members of...Ch. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - To delete a specific character in a StringBuilder...Ch. 9 - Prob. 12MCCh. 9 - Prob. 13MCCh. 9 - These static final variables are members of the...Ch. 9 - Prob. 15TFCh. 9 - Prob. 16TFCh. 9 - True or False: If toLowerCase methods argument is...Ch. 9 - True or False: The startsWith and endsWith methods...Ch. 9 - True or False: There are two versions of the...Ch. 9 - Prob. 20TFCh. 9 - Prob. 21TFCh. 9 - Prob. 22TFCh. 9 - Prob. 23TFCh. 9 - int number = 99; String str; // Convert number to...Ch. 9 - Prob. 2FTECh. 9 - Prob. 3FTECh. 9 - Prob. 4FTECh. 9 - The following if statement determines whether...Ch. 9 - Write a loop that counts the number of space...Ch. 9 - Prob. 3AWCh. 9 - Prob. 4AWCh. 9 - Prob. 5AWCh. 9 - Modify the method you wrote for Algorithm...Ch. 9 - Prob. 7AWCh. 9 - Look at the following string:...Ch. 9 - Assume that d is a double variable. Write an if...Ch. 9 - Write code that displays the contents of the int...Ch. 9 - Prob. 1SACh. 9 - Prob. 2SACh. 9 - Prob. 3SACh. 9 - How can you determine the minimum and maximum...Ch. 9 - Prob. 1PCCh. 9 - Prob. 2PCCh. 9 - Prob. 3PCCh. 9 - Prob. 4PCCh. 9 - Prob. 5PCCh. 9 - Prob. 6PCCh. 9 - Check Writer Write a program that displays a...Ch. 9 - Prob. 8PCCh. 9 - Prob. 9PCCh. 9 - Word Counter Write a program that asks the user...Ch. 9 - Sales Analysis The file SalesData.txt, in this...Ch. 9 - Prob. 12PCCh. 9 - Alphabetic Telephone Number Translator Many...Ch. 9 - Word Separator Write a program that accepts as...Ch. 9 - Pig Latin Write a program that reads a sentence as...Ch. 9 - Prob. 16PCCh. 9 - Lottery Statistics To play the PowerBall lottery,...Ch. 9 - Gas Prices In the student sample program files for...
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
- C sharp Write a method that accepts a string as an argument and checks it for proper capitalization and punctuation. The method should determine if the string begins with an uppercase letter and ends with a punctuation mark. The method should return true if the string meets the criteria; otherwise, it should return false.arrow_forward1. A showChar MethodWrite a method named showChar. The method should accept two arguments: a reference toa String object and an integer. The integer argument is a character position within theString, with the first character being at position 0. When the method executes, it shoulddisplay the character at that character position. The method does not return anything.Here is an example of a call to the method:showChar("New York", 2);In this call, the method will display the character w because it is in position 2. Demonstratethe method in a complete program-- use the class name Method_showChar Javaarrow_forwardThe __________ of a string object allow you to search for substrings. a. TrimStart and TrimEnd methods b. IndexOf and LastIndexOf methods c. IsWhiteSpace and IsPunctuation methods d. Contains, StartsWith, and EndsWith methodsarrow_forward
- JAVA PPROGRAM ASAP Please create this program ASAP BECAUSE IT IS MY LAB ASSIGNMENT so it passes all the test cases. The program must pass the test case when uploaded to Hypergrade. Chapter 9. PC #2. Word Counter (page 608) Write a method that accepts a String object as an argument and returns the number of words it contains. For instance, if the argument is “Four score and seven years ago” the method should return the number 6. Demonstrate the method in a program that asks the user to input a string and then passes it to the method. The number of words in the string should be displayed on the screen. Test Case 1 Please enter a string or type QUIT to exit:\nHello World!ENTERThere are 2 words in that string.\nPlease enter a string or type QUIT to exit:\nI have a dream.ENTERThere are 4 words in that string.\nPlease enter a string or type QUIT to exit:\nJava is great.ENTERThere are 3 words in that string.\nPlease enter a string or type QUIT to exit:\nquitENTERarrow_forwardWord Separator Create an application that accepts as input a sentence in which all the words are run together but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRoses." would be converted to "Stop and smell the roses."arrow_forwardStaff # name: String # id: int PartTimer + Staff() + Staff(name: String, id: int) skillLevel: int + getName (): String + getId (): int + calculatePay () : double + toString (): String hoursWorked: int + Part Timer (name: String, id: int, skillLevel: int, hoursWorked: int) + getskillLevel(): int + getHours Worked () : int + tostring () : String java.lang.Comparable compareTo (o: Object): int Figure 1: The relationship between staff, PartTimer and Comparable Skill Level / Tahap Kemahiran Pay Rate Per Hour/ Kadar Bayaran Per Jam 0 ( Basic / Asas) RM50.00 1 (Moderate / Sederhana) RM100.00 RM150.00 2 (Expert / Mahir) Table 1: Skill level and the pay rate per hour Write a complete Java program to create PartTimer class and test class based on the Figure 1, Table 1 and the following requirements: Partimer class is derived from staff and implements Comparable Interface. The calculate Pay()method from the staff class will be implemented in the subclass to calculate the employee's pay. The pay…arrow_forward
- public String firstAndLast(String str) { //declare and create your first char //declare and create your second char //return your first and last char as a String }arrow_forward5. public static String getFlag(int size, char color1, char color2, char color3) - This method returns a string where a triangle appears on the left size of the diagram, followed by horizontal lines. For example, calling DrawingApp.getFlag(9, 'R', '.', 'Y'); will generate the string: R... RRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY RRRYYYYΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥ YYYYYYYYY RRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY RRRRRYYYYY YYYYYYYYYYYYY YYYYYYYYY RRRRRRY YYYYYYYYYYYYYYYYY YYYYYYYYY RRRRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY RRRRRRRRYY YYYYYYYYYYYYYYYY YYYYYYYYY RRRRRRRRR. RRRRRRRRR. RRRRRRRRYYYYYY rҮҮҮҮҮҮҮҮҮҮҮҮҮҮҮҮҮҮ YYYYYYYYY RRRRRRRYYY ΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥ ΥΥΥΥΥΥΥΥΥ RRRRRRYYY ΥΥΥΥΥΥΥΥΥΥΥΥΥΥΥ YYYYYYYYY RRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY RRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY RRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY RRYYYYYYYY YYYYYYYYYYYYYYYY ΥΥΥΥΥΥΥ The diagram has a number of rows that corresponds to size * 2 and a number of colums that…arrow_forwardThe ________ method parses a string s to a double value. double.parseDouble(s); Double.parsedouble(s); Double.parseDouble(s); double.parse(s);arrow_forward
- 2. The Integer.parseInt () method requires a String argument, but fails if the String cannot be converted to an integer. Write an application in which you try to parse a String that does not represent an integer value. Catch the Number FormatException that is thrown, and then display an appropriate error message. Save the file as Try ToParseString.java.arrow_forwardAll the Same Letter Write a method to determine if all the letters in a String are the same letter. public boolean sameLetter(String str) { //declare first character variable //create statements to compare each character and include return statement //create other return statement }arrow_forwardMicrosoft Visual C# 7th edition Create a program for Smalltown Regional Airport Flights that accepts either an integer flight number or string airport code from the options in Figure 8-33. Pass the user’s entry to one of two overloaded GetFlightInfo() methods, and then display a returned string with all the flight details. For example, if 201 was input, the output would be: Flight #201 AUS Austin Scheduled at: 0710 (note that there should be two spaces between 'Austin' and 'Scheduled'). The method version that accepts an integer looks up the airport code, name, and time of flight; the version that accepts a string description looks up the flight number, airport name, and time. The methods return a message if the flight is not found. For example, if 100 was input, the output should be Flight #100 was not found. If no flights were scheduled for the airport code entered, for example MCO, the message displayed should be Flight to MCO was not found. I am having these errors 1-…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
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