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
Textbook Question
Chapter 9, Problem 2AW
Write a loop that counts the number of space characters that appear in the String object str.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Name format: You must use String object and not StringBuffer or StringBuilder.
Many documents use a specific format for a person's name. Write a program that take one
Line as an input.
Example:
Scanner input = new Scanner(System.in);
System.out.println(“Enter firstName middleName lastName separated by at least one
blank, It may have more than one blank separating firstName middleName lastName.");
Input sample : Pat Silly Doe || Note these are separated by at least one blank.
String line = input.nextLine()
Ex: If the input is:
Pat Silly Doe
the output is:
Doe, P.S.
If the input has the form:
firstName lastName
the output is:
lastName, firstInitial.
Ex: If the input is:
Julia Clark
the output is:
Clark, J.
Please submit the .java source file and the sample run in a text file. Thanks
Learning Objectives: Python Programming
Use loop over a stringReplace characters within a stringFunction (declaration and call)Write code in modular formInstructions
Create a function only_chars that takes the line of text and returns the text line excluding the spaces, periods, exclamation points, or commas.
Create a program that will read the input line, use the function, and then print the line, without spaces, periods, exclamation marks, or commas and their length.
Ex: If the input is:
Listen, Mr. Jones, calm down.
the output is:
ListenMrJonescalmdown21Do not forget if __name__ == "__main__" section!
Q: People often forget closing parentheses when entering formulas. Write a program that asks the user to enter a formula and prints out whether the formula has the same number of opening and closing parentheses.
Q: Write a program that asks the user to enter a word and prints out whether that word contains any vowels.
Q: Write a program that asks the user to enter a string. The program should create a new string called new_string from the user’s string such that the second character is changed to an asterisk and three exclamation points are attached to the end of the string. Finally, print new_string. Typical output is shown below: Enter your string: Qbert Q*ert!!!
Q: Write a program that asks the user to enter a string s and then converts s to lowercase, removes all the periods and commas from s, and prints the resulting string.
Q: Write a program that asks the user to enter a word and determines whether the word is a palindrome or not. A palindrome is a word that reads the same…
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is an object?
Starting Out With Visual Basic (8th Edition)
Write an SQL query to list all product line names and, for each product line, the number of products and the av...
Modern Database Management
The classs________ are the statements that define the classs fields, properties, and methods. a. data agents b....
Starting out with Visual C# (4th Edition)
(Display an integer reversed) Write a method with the following header to display an integer in reverse order: ...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Demonstrate each of the anomaly types with an example.
Modern Database Management (12th Edition)
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
- Planets = [‘Mercury’, ‘Venus’, ‘Earth’, ‘Mars’, ‘Jupiter’, ‘Saturn’, ‘Uranus’, ‘Neptune’] Use a loop and print out the name of the planet with the shortest amount of characters.arrow_forwardFunction strlen() takes a string as an argument and returns the number of characters in the string, Which of the following is the correct answer to fill the above statement with it? Select one: a. Spaces are not included in the length calculation b. Null character is not included in the length calculation c. Numbers are not included in the length calculation d. Null character is included in the length calculationarrow_forwardwrite programs date formarrow_forward
- This application accepts an arbitrary number of user inputs. Every time this application receives a string, it should add the string to a growing string.Newly added strings should be added to the growing string at the index equal to the newly added string's length.arrow_forward5. Maximum Occurring Character Given a string, return the character that appears the maximum number of times in the string. The string will contain only ASCII characters, from the ranges ('a'-'z','A'-'Z','0'-'9'), and case matters. If there is a tie in the maximum number of times a character appears in the string, return the character that appears first in the string. Example text = abbbaacc Both 'a' and 'b'occur 3 times in text. Since 'a'occurs earlier, a is the answer. Function Description Complete the function maximum Occurring Character in the editor below. maximumOccurringCharacter has the following parameter: string text: the string to be operated upon Returns char: The most occurring character that appears first in the string. Constraints • 10 ≤ |text| ≤ 104 • All characters are alphanumeric, in the ranges ('a'-'z','A'-'Z','0'-'9') ======== 999992 14 15 16 17 18 19 20 21 2 2 2 2 22 23 24 25 2222 26 class Result { * * Complete the 'maximumOccurring Character' function below. * का…arrow_forward1. In the first loop, the low number will be the starting point for the loop and thehigh will be the ending point. The loop should display the iterator number andthat number x 10 on the same line, separated by a tab. See example on p. 177.2. The second loop should accumulate all the numbers between the starting pointand ending point. You will need to create and initialize an accumulator such astotal before you start the loop.arrow_forward
- Lab Goal : This lab was designed to teach you how to use a while loop. Lab Description (JAVA PROGRAMMING): Remove all occurrences of the removal string from the original string. Each time you take out the removal string you must also remove the letter that preceded the removal string. After you remove a string and its leading character, you must check to see if any more occurrences of the removal string exist. Sample Data : xR-MxR-MHelloxR-M R-M sxsssxssxsxssexssxsesss xs fuxqwexqwertyxqwexqwe Sample Output : xR-MxR-MHelloxR-M - String to remove R-M Hello sxsssxssxsxssexssxsesss - String to remove xs sesss fuxqwexqwertyxqwexqwertyrtyxqwertyrtyn - String to remove qwerty fun dogdogcatddodogdogdoggog - String to remove dog catgog algorithm help use indexOf to look for more removals while you have more removals { take out the current removal using substring use indexOf to look for more removals } I need help with assignment: "String Cleaner" StringRemover.js: //(c) A+…arrow_forward1. This program reads one number, as a string, and assign it to String getData Increment and display getData as integer and double Only strings are to be read 2. This program reads strings only Read ten digits, such as 2345678923 store them in getData, which is a string Display each value and it position in the stringarrow_forwardTrue or False: The String class’s replace method can replace individual characters, but cannot replace substrings.arrow_forward
- Downlollllarrow_forwardHelparrow_forwardPalindrome Checkercreate a JavaScript program that checks if phrasesentered by the user are palindromes. A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as “SIR”,“raceBIKE”, “Never odd or even”, “20/1/20”. The program should prompt the user to typein a phrase that is at least three characters long, and then tell the user whether the phrasewas a palindrome. Note, the decision should be based solely on letters and numericaldigits, and so it should not consider other characters, such as spaces or exclamationmarks, even though these might be entered by the user. when checking palindromes.A. Select your test data with care. Both palindromes and non-palindromes would be included in this. Provide examples that are text, numeric, and mixed; ignore any additional characters and spaces; andB. Ask the user for the word and then read their input. To verify that their input string has been read correctly, test this by displaying…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Control Structures - while loop - do-while loop - for loop - Goto - break - continue statements; Author: EzEd Channel;https://www.youtube.com/watch?v=21l11_9Osd0;License: Standard YouTube License, CC-BY