Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9, Problem 6E
Write code that reads a string from the keyboard and uses it to set the variable myTime of type TimeofDay from the previous exercise. Use try–catch blocks to guarantee that myTime is set to a valid time.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The loop below is intended to collect all characters that occur more than once in a given string. When you try it out with a string such as “Mississippi”, you will note that that letters that occur three or more times are collected more than once. Modify the loop so that each repeated letter is collected exactly once.
For example, when s is “Mississippi”, result should be “si” and not “sissii”
Only allowed to edit code in the /* Your code goes here */ portion.
Thanks for the help!
can you please show me with the screen shot of the output, Thank you.
Write a method that finds the number of occurrences of a specified character in a string using thefollowing header:public static int countLetter(String str, char ch)Write a test program that prompts the user to enter a word and a letter of the alphabet. Theprogram should then count and display the number of occurrences of the letter in the word. Asample dialog for the program is shown below:
Chapter 9 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 9.1 - Prob. 1STQCh. 9.1 - What output would the code in the previous...Ch. 9.1 - Prob. 3STQCh. 9.1 - Prob. 4STQCh. 9.1 - Prob. 5STQCh. 9.1 - Prob. 6STQCh. 9.1 - Prob. 7STQCh. 9.1 - Prob. 8STQCh. 9.1 - In the code given in Self-Test Question 1,...Ch. 9.1 - In the code given in Self-Test Question 1,...
Ch. 9.1 - Prob. 11STQCh. 9.1 - Prob. 12STQCh. 9.1 - Prob. 13STQCh. 9.1 - Prob. 14STQCh. 9.2 - Prob. 15STQCh. 9.2 - Prob. 16STQCh. 9.2 - Prob. 17STQCh. 9.2 - Prob. 18STQCh. 9.2 - Prob. 19STQCh. 9.2 - Prob. 20STQCh. 9.2 - Suppose that, in Self-Test Question 19, we change...Ch. 9.2 - Prob. 22STQCh. 9.2 - Prob. 23STQCh. 9.3 - Prob. 24STQCh. 9.3 - Prob. 25STQCh. 9.3 - Prob. 26STQCh. 9.3 - Prob. 27STQCh. 9.3 - Prob. 28STQCh. 9.3 - Repeat Self-Test Question 27, but change the value...Ch. 9.3 - Prob. 30STQCh. 9.3 - Prob. 31STQCh. 9.3 - Prob. 32STQCh. 9.3 - Consider the following program: a. What output...Ch. 9.3 - Write an accessor method called getPrecision that...Ch. 9.3 - Prob. 35STQCh. 9.4 - Prob. 36STQCh. 9.4 - Prob. 37STQCh. 9.4 - Prob. 38STQCh. 9 - Write a program that allows students to schedule...Ch. 9 - Prob. 2ECh. 9 - Prob. 3ECh. 9 - Prob. 4ECh. 9 - Prob. 5ECh. 9 - Write code that reads a string from the keyboard...Ch. 9 - Create a class Rational that represents a rational...Ch. 9 - Prob. 9ECh. 9 - Suppose that you are going to create an object...Ch. 9 - Revise the class RoomCounter described in the...Ch. 9 - Prob. 12ECh. 9 - Write a class LapTimer that can be used to time...Ch. 9 - Prob. 1PCh. 9 - Prob. 2PCh. 9 - Prob. 3PCh. 9 - Write a program that uses the class calculator in...Ch. 9 - Prob. 3PPCh. 9 - Prob. 7PPCh. 9 - Suppose that you are in change of customer service...Ch. 9 - Write an application that implements a trip-time...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What does the following code print? System.out.print(""); System.out.println(""); System.out.println(""); Syste...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Write Python code that prompts the user to enter his or her favorite color and assigns the users input to a var...
Starting Out with Python (4th Edition)
Suppose a manufacturer produces a computer chip and later discovers a flaw in its design. Suppose further that ...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
What populates the Smalltalk world?
Concepts Of Programming Languages
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
- The countSubstring function will take two strings as parameters and will return an integer that is the count of how many times the substring (the second parameter) appears in the first string without overlapping with itself. This method will be case insensitive. For example: countSubstring(“catwoman loves cats”, “cat”) would return 2 countSubstring(“aaa nice”, “aa”) would return 1 because “aa” only appears once without overlapping itself. public static int countSubstring(String s, String x) { if (s.length() == 0 || x.length() == 0) return 1; if (s.length() == 1 || x.length() == 1){ if (s.substring(0,1).equals(x.substring(0,1))){ s.replaceFirst((x), " "); return 1 + countSubstring(s.substring(1), x); } else { return 0 + countSubstring(s.substring(1), x); } } return countSubstring(s.substring(0,1), x) + countSubstring(s.substring(1), x); } public class Main { public static void main(String[] args) { System.out.println(Recursion.countSubstring("catwoman loves cats","cat"));…arrow_forward/** 2. Write the method named countChar() * You are given a String str, and a char ch. Return the number of times that ch appears inside str, but ignore case. * * * Oh, and you can't use the classification methods in the Character class. Use plain if statements, remembering that you can check if ch is lowercase by checking if it is between lowercase 'a' and lowercase 'z', inclusive. Likewise, check if between 'A' and 'Z' for capital. To convert lowercase to uppercase, subtract the difference between lowercase 'a' and uppercase 'A' ('a'-'A') from the lowercase character. Add this difference to convert from uppercase to lowercase. * * * * * * Examples: countChar("Abcdefg", 'a') returns 1 countChar("xxXx", 'x') returns 4 countChar("", 'q') returns 0 * * @param str the String to search through @param ch the char to count (not case sensitive) @return the count of ch in str * */ public int countChar(String str, char ch) { // Complete the countChar method here }arrow_forwardJavaarrow_forward
- 3. in pyth code pleasearrow_forwardCreate a function that tracks how many times a phrase appears in a string. An number must be returned by the function. Never presume that a string of words can contain punctuation and only one space between words. Create the method with either a String argument or a StringBuilder object so that it can be used.arrow_forwardWrite an application that reads a five-letter word from the user and produces every possible three-letter string that can be derived from the letters of that word. For example, the three-letter words produced from the word “bathe” include “ate,” “bat,” “bet,” “tab,” “hat,” “the” and “tea.”arrow_forward
- Use the compareTo method to write code that reads two names from the console and prints the one that comes first in alphabetical order. For example, the program's output might look like the following: Type a name: Tyler Durden Type a name: Marla Singer Marla Singer goes before Tyler Durdenarrow_forwardDeclare a string variable that has the word "TEST" in it 500 times.arrow_forwardSignature will be public static void changeLetter(StringBuilder sb, String Letters) Make it so any letters from the second parameter found in the String Builder are converted to uppercase. Write in Java and use testcase examples as a reference.arrow_forward
- Create class that performs different functions on Strings that are sent to it. All the methods you create will be static. Only two methods (mentioned below) and the main method need to be public. Any other methods that you write to help these methods should be private because they are only used internally within the class. Requirements: 1. Prompt users to enter 3 string inputs. Consider strings with alphabetic characters (a - z, A - Z) and/or numbers (0 - 9) as valid. Strings contain only non-word characters are invalid. Print the following usage when an input string is invalid or is empty. Usage: Enter a string that contains alphabetic characters and numbers 2. Create a method "isPalindrome" that takes a String as a parameter and returns true if the given String parameter is a palindrome and false if it is not. In your main method, this method should be call with the first user input and print either "The given string is a palindrome." or "The given string is not a palindrome." as…arrow_forwardTry to do asap And do not copy from other sources Write your own code with necessary comments.arrow_forward2. Accept any single capital letter alphabet and a positive integer between 1 to 10 from the user. Generate the triangular pattern out of it. The number of rows in the pattern should be equal to the integer number accepted from the user. Add appropriate validations such as the character is alphabet and capital letter. Also validate if the integer is a positive number between 1 to 10. E.g. If character entered is 'G', then output should be as follows: G G G G G G G G G G Croato a structure to store the information about name of account holder, existing balance.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY