Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 14STE
Write a complete Java
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program IN JAVA to simulate a calculator for String values. The program should take three inputs from the user.
The first two inputs are of type String. The user may enter any text.
The third input is also a String but limited to one of these words – concat, contains, and equal. These words indicate operations that can be performed on the previous two strings.
Example 1: if the user entered the following (bold text is user input):
Enter String 1: Hello
Enter String 2: World
Enter String 3: Concat
Your program should join/concatenate Hello and World to print “Hello World”
Example 2: if the user entered the following (bold text is user input):
Enter String 1: My name is Joe
Enter String 2: Joe
Enter String 3: Contains
Your program should check if Joe is contained in My name is Joe and print the result of the operation with a helpful message, ““Joe” is contained in “My name is Joe””
Example 3: if the user entered the following
Enter String 1: Hello
Enter String 2: Hello
Enter…
Write a java program that reads a line of input as a sentence and displays:• Only the uppercase letters in the sentence.• The sentence, with all lowercase vowels (i.e. “a”, “e”, “i”, “o”, and “u”) replaced by a strikesymbol “*”.
Write a complete Java program that reads in a line of text containing exactlythree words (separated by any kind or amount of whitespace) and outputs theline with spacing corrected; that is, the output has no space before the firstword and exactly one space between each pair of adjacent words.
Chapter 2 Solutions
Absolute Java (6th Edition)
Ch. 2 - Prob. 1STECh. 2 - Write Java statements that will cause the...Ch. 2 - What is the difference between System.out.println...Ch. 2 - Prob. 4STECh. 2 - What output is produced by the following code?
Ch. 2 - What output is produced by the following code? For...Ch. 2 - Write a Java statement to output the value in...Ch. 2 - What output is produced by the following code?...Ch. 2 - Suppose the class Robot is a part of the standard...Ch. 2 - Write an import statement that makes the Scanner...
Ch. 2 - Prob. 11STECh. 2 - Write a line of code that uses the object frank...Ch. 2 - Write a complete Java program that reads in a line...Ch. 2 - Write a complete Java program that reads in a line...Ch. 2 - Something could go wrong with the following code....Ch. 2 - Suppose your code creates an object of the class...Ch. 2 - Continue with the object keyboard from Self-Test...Ch. 2 - Prob. 18STECh. 2 - What is missing from the following code, which...Ch. 2 - The Babylonian algorithm to compute the square...Ch. 2 - (This is a version with input of an exercise from...Ch. 2 - Write a program that reads in two numbers typed on...Ch. 2 - John travels a distance of 55 miles at an average...Ch. 2 - Grade point average (GPA) in a 4-point scale is...Ch. 2 - (This is a better version of an exercise from...Ch. 2 - Write a program that determines the change to be...Ch. 2 - Write a program that reads in a string containing...Ch. 2 - (This is a better version of an exercise from...Ch. 2 - Write a program that inputs the name, quantity,...Ch. 2 - Write a program that calculates the total grade...Ch. 2 - (This is a variant of an exercise from Chapter 1.)...Ch. 2 - (This is an extension of an exercise from Chapter...Ch. 2 - From Programming Project 10 in Chapter 1,...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
In Exercises 1 through 52, determine the output produced by the lines of code. DimlastName,message,firstNameAsS...
Introduction To Programming Using Visual Basic (11th Edition)
What is a constructor?
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
This is the first index in a string. a. 1 b. 1 c. 0 d. The size of the string minus one
Starting Out with Python (4th Edition)
For what types of applications might thermit welding be attractive?
Degarmo's Materials And Processes In Manufacturing
This key word refers to an objects superclass. a. super b. base c. superclass d. this
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
T F Binary files contain unformatted data, not necessarily stored as text.
Starting Out with C++ from Control Structures to Objects (9th 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
- Write a Java program (TicTacToe.java) for playing tic-tac-toe. You may assume that two human players are playing against each other. Your program should display an updated board before every turn, prompt the user to enter the row and column in which to play, and display "X wins!", "O wins!", or "Tie!" at the end of the game. Here is a sample run of a correct program (user input indicated by orange text):Let's play Tic-Tac-Toe! - - -- - -- - -Enter a row and column (1, 2, 3) for player X: 2 2 - - -- X -- - -Enter a row and column (1, 2, 3) for player O: 2 3 - - -- X O- - -Enter a row and column (1, 2, 3) for player X: 1 1 X - -- X O- - -Enter a row and column (1, 2, 3) for player O: 1 3 X - O- X O- - -Enter a row and column (1, 2, 3) for player X: 3 3 X - O- X O- - XX wins!arrow_forwardWrite a JAVA program that checks phrases to determine if they are palindromes. A palindrome is a word, phrase, or sentence that reads left-to-right the same way it reads right-to-left, ignoring all punctuation and capitalization. For example, the statement “Madam, I’m Adam” is a palindrome as the response of “Eve.” Use a method to determine if a String is a palindrome. Test a single word non-palindrome, a single word palindrome, a phrase that is not a palindrome, and a phrase that is a palindrome. Print the phrase and whether it is a palindrome or not. Some simple palindromes are “racecar,” “taco cat,” and “A man, a plan, a canal, Panama!” There are a few different approaches for the test; choose one of your liking. Hint: extract all letters, change the remaining letters to lowercase, then test if the phrase is a palindrome.arrow_forwardWrite a JAVA program that reads one line of input text and breaks it up into words. The (solution) words should be output one per line. A word is defined to be a sequence of letters. Any characters in the input that are not letters should be discarded. For example, if the user inputs the line He said, "That’s not a good idea." then the output of the program should be HesaidThatisnotagoodidea An improved version of the program would list “that’s” as a single word. An apostrophe can be considered to be part of a word if there is a letter on each side of the apostrophe. To test whether a character is a letter, you might use (ch >= ’a’ && ch <= ’z’) || (ch >= ’A’ && ch <= ’Z’). However, this only works in English and similar languages. A better choice is to call the standard function Character.isLetter(ch), which returns a boolean value of true if ch is a letter and false if it is not. This works for any Unicode character.arrow_forward
- Write a JAVA program that would match a string. It accepts two inputs: the phrase/sentence string (text) and the pattern string (word). The program finds the first (or all) instances of the pattern in the text and changes that word in all uppercase and displays its number of occurrences. Sample Input: Text string: You will always have my love, my love, for the love I love is as lovely as love itself. Pattern string: love Sample Output: New text: You will always have my LOVE, my LOVE, for the LOVE I LOVE is as lovely as LOVE itself. Number of occurrence: 5arrow_forwardWrite a Java program using at least one for loop that prints pictures of piles of counters of different sizes using ‘=‘ characters as shown below. Each counter should be an odd number of characters wide and be two characters longer than the counter above it. The user should, when asked, type in the size of the top and bottom counters. For example, if the user enters 3 for the top counter and 7 for the bottom counter then the image below should be printed. your program must make use of a counter-controlled for loop be in procedural programming style (not OOP) your program should also be logically correct, solving the core problem, be elegantly written following good style, and be broken into appropriate methods that take arguments and/or return results.arrow_forward3. Write a Java program that takes the user to provide a single character from the alphabet. Print Vowel or Consonant, depending on the user input. If the user input is not a letter (between a and z or A and Z), or is a string of length > 1, print an error message.4. Write a program in Java to input 5 numbers from keyboard and find their sum and average.arrow_forward
- Use Java Implement a game of Pig where the user plays against a "hold at 20 or goal" computer player that rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20, or the score plus the turn total is greater than or equal to 100. The first player is chosen randomly. An empty input (i.e., Enter) indicates that the user wishes to roll. Any entered line of non-zero length indicates that the user wishes to hold. Before the game, randomly select which player the user will be, and print the line "You will be player #.", where # is the user's player number. Then, print an instruction line "Enter nothing to roll; enter anything to hold." Before each turn, print a line with "Player 1 score: " and player 1's score. Print another line with "Player 2 score: " and player 2's score. Finally, print a line with "It is player #'s turn.", where "#" is replaced by the current player number. Play starts with player 1 and then alternates. For each roll, print a line with…arrow_forwardWrite a Java program that asks a user to enter his/her age. If the user's age is in the range of [18, 150] (18 ≤ age ≤ 150), program prints “Old enough!”, when the given age is smaller than the given range it must print “Too young”, and otherwise prints "Incorrect age."arrow_forward13. Write a Java program that reads two integers num1 and num2. If num1 is greater than num2, then swap (exchange) them. Next, your program must display all numbers from num1 to num2 on a single line such that every line contains the number followed by all its divisors (see sample input/output below.) Sample Input/Output Enter two numbers: 20 25 Number Divisors 20 4 10 20 21 21 22 11 22 23 23 24 4 12 24 25 25arrow_forward
- Write a java program that would match a string. It accepts two inputs: the phrase/sentence string (text) and the pattern string (word). The program finds the first (or all) instances of the pattern in the text andchanges that word in all uppercase and displays its number of occurrences. Sample Input:Text string: You will always have my love, my love, for the love I love is as lovely as love itself. Pattern string: love Sample Output:New text: You will always have my LOVE, my LOVE, for the LOVE I LOVE is as lovely as LOVE itself. Number of occurrence: 5arrow_forwardWrite a java program that repeatedly prompts the user to input a string starting with letters from the English alphabet. The program must stop getting input when the user inputs the string “STOP” Consider The word STOP as case insensitive (i.e. STOP = stop = Stop = Stop ….) . Then the program must display the words starting with each letter (Case-Sensitive) from the alphabet in a separate line (e.g. you need to make a new line after all words starting with a specific letter are finished. Your program must be written according to the following rules: 1- Create an array list of 52 linked lists. 2- Each linked list will have the strings starting with a specific letter each in a separate node. For example element 0 in the array list will have a linked list of the strings starting with a and element 1 in the array list will have a linked list of the Strings starting with A, element 2 in the array list will have a linked list of the strings starting with b element 3 in the…arrow_forwardWrite a FULL Java procedural program for a simple word guessing game. Below is an example of the required program behaviour. The bold text is user keyboard input. The player is allowed to guess one letter or the whole word incorrectly up to 5 times; each incorrect guess is called a “strike”. The program starts by displaying one full stop (’.’) for each character of the secret word. You may assume the word is hardcoded into the game, is in lower case, and is of length greater than one. In each round of the game, the game first checks if the player has reached the maxinum number of strikes; if so, the player loses and the game ends. If not, the game prints an input prompt. The player then guesses either one letter (by entering a single character) or the whole word (by entering multiple characters). If a single letter is guessed correctly, meaning the character occurs in the word, the game reveals the positions of those occurrences in the word and proceeds to the next round. If the whole…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
The Top Down Approach to Software Development; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=v9M8LA2uM48;License: Standard YouTube License, CC-BY