EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Signature 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.
Write 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.”
Q1) Write a method that checks whether two words are anagrams. Two words are anagrams if they contain the same letters in any order. For example, "silent" and "listen" are anagrams. Write a test program that prompts the user to enter two strings and, if they are anagrams, displays "anagram", otherwise displays "not anagram".
Note: The header of the method is as follows:
public static boolean isAnagram(String s1, String s2)
Sample Input #1:
Enter two strings:
Silent
listen
Sample Output #1:
The string “Silent” and “listen” are anagrams.
Sample Input #1:
Enter two strings:
teach
peach
Sample Output #1:
The string “teach” and “peach” aren’t anagrams.
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
- What is the value of the String S after the following line? String S, s1 ="arach",s2 = "nophobia” ; S =s1.substring(0,2) +s2.substring(3); a. "arachobia" b. "arnophobia" c. "rachobia" d. "arhobia"arrow_forward******* In java ***** create a class , and objects for the following exercise 1- for car car - make -yearModel + setMake() + setYearModel() + getMake() + getYearModel() 2- for cellphone cellPhone - manufact : String - model : String - retailPrice : double + setManufact(man : String) : void + setModel(mod : String) : void + setRetailPrice( price : double) : viod + getManufact() : String + getModel() : String + getRetailPrice() : doublearrow_forwardU is upward, D is downward, L is left and R is right : Using the methods pickDir() and exractInt() as shown below, to write a simple automated game: how long does it take a robot to travel from a left line of a field to the right line? Assume field is 15 units apart (meters, kilometers, it doesn’t matter), and the robot starts on the left line. pickDir(): // return string with random direction and random distance (within maxDist) public static String pickDir (int maxDist) { Random r = new Random(); // random number generator // return direction + distance return ( "" + "LRUD".charAt( r.nextInt(4) ) + (r.nextInt(maxDist) + 1) ); } extractInt(): // returns integer from string, from pos p1 to p2: str = "D1" – extractInt(str,1,1); public static int extractInt (String str, int p1, int p2) { return ( Integer.parseInt( str.substring(p1, p2+1) ) ); } Write the main() method that keeps looping until the robot’s random left…arrow_forward
- In java language Before we write a class which is used to describe objects, let’s practice manipulating an object by calling its methods. Complete the class LeetMaker class using String methods. Remember that all the String methods are accessors. They do not change the original String. If you want to apply multiple methods to a String, you will need to save the return value in a variable. Complete the class by doing the following: Print the word in lowercase Replace "e" with "3" (Use the unmodified variable word) Print the changed word In the changed word, replace: "t" with "7" Print the changed word In this newest changed word, replace: "L" with "1" (uppercase L with the number 1). Then, print the final changed word (with all the replacements) Print the length of the word The code to print the original word is already included for you. Do not change that statement. You will need to use the replace() method multiple times. Then print the final String. Remember that replace is an…arrow_forward/* This is the code for the Word Jumble game from Chapter 3. Improve the Word Jumble game by adding a scoring system. Make the point valuefor a word based on its length. Deduct points if the player asks for a hint. */ // Word Jumble// The classic word jumble game where the player can ask for a hint #include <iostream>#include <string>#include <cstdlib>#include <ctime> using namespace std; int main(){ enum fields {WORD, HINT, NUM_FIELDS}; const int NUM_WORDS = 5; const string WORDS[NUM_WORDS][NUM_FIELDS] = { {"wall", "Do you feel you're banging your head against something?"}, {"glasses", "These might help you see the answer."}, {"labored", "Going slowly, is it?"}, {"persistent", "Keep at it."}, {"jumble", "It's what the game is all about."} }; srand(static_cast<unsigned int>(time(0))); int choice = (rand() % NUM_WORDS); string theWord = WORDS[choice][WORD]; //word to guess string theHint =…arrow_forwardWrite a method specification for the method below.public String getDefinitionFromDictionary(String word)arrow_forward
- Write a method that accepts a String object as an argument and displays its contents backward.For instance, if the string argument is “gravity” the method should display -“ytivarg”.Demonstrate the method in a program that asks the user to input a string and then passes itto the method.arrow_forwardBriefly describe each of the following string object methods: TrimStartarrow_forwardWrite a program in the StringManipulator class that creates a String variable that references a String object holding the name of your favorite city. The program should display the following: • The number of characters in the city name• The name of the city in all uppercase letters • The name of the city in all lowercase letters • The first character in the name of the cityarrow_forward
- 3- What is the output of the following program? Why?public class Student {public String getDepartment() {return "general";}public String getStudInfo() {return this.getDepartment();}}public class CSStudent extends Student {public String getDepartment() {return "CS";}}public class Main{public static void main(String[]args){Student s1 = new CSStudent();s1.getStudInfo();}}arrow_forwardPlease explain Common String Mistake in the code below/question in Bold: public class StringMistakeDemo{public static void main(String[] args) {String a = "Roux";String b = "Roux";String c = new String("Roux"); /** Number 1* Consider the output from the this block of code. * Which line causes the "false"?* Why are the last two lines different?*/System.out.println();System.out.println("Roux" == "Roux"); //comparing two stringsSystem.out.println(a == b); //comparing two string variablesSystem.out.println(a == c); //comparing two other string variablesSystem.out.println(a.equals(c));//using the string class method "equals"/** Number 2* "identityHashCode" provides a numeric signature that includes the * memory location for the variable. * What does the following output tell you about how Java stores…arrow_forwardAssume below basic skeleton of Student and GradeBook class: public class GradeBook { private String courseName; private Student[] students; // ... other methods .... } public class Student{ private int id; private String name; int marks[]; // marks in different tests } Encapsulate fields and defined needed constructors. Then, make a GradeBook object and fully initialize it based on user input. Get number of students from user input. As number of tests each student given may be different, so your program shall take number of tests and marks in each test, form user input too. You can also generate and use random number to quickly initialize whole data, instead of getting from user, but choose decent ranges e.g. maximum marks 100, maximum students 50 and maximum number of test each student may give shall be less or equal to 10. After fully initializing the GradeBook object, print following information: Which student given maximum number of test, print student id Who got maximum…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning