Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Write a method that takes a given string and replaces all occurrences of one string with another string, returning the number of replaces made. For instance, given the string “Microsoft” if you were to replace all occurrences of “ic” with “MSFT” the result would be “MMSFTrosoft” with a return value of 1. As part of a final solution please provide unit tests done as well as any test cases ran. Please note that you may not use String.Replace or string:replace depending upon the language you use; you must write this functionality yourself.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 4 images
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 method myConcat that takes a string of multiple words and it returns a string made up of all the words concatenated together with the whitespace removed.arrow_forwardThe method printGroupSize() has an integer parameter. Define a second printGroupSize() method that has a string parameter. The second method outputs the following in order, all on one line: "A group of " the value of the string parameter "." End with a newline. Ex: If the input is 7 seven, then the output is: Order for size: 7 A group of seven. 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 public class GroupSize { publicstaticvoidprintGroupSize(intgroupSize) { System.out.println("Order for size: "+groupSize); } /* Your code goes here */ publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); intsizeOfGroup; StringsizeInWord; sizeOfGroup=scnr.nextInt(); sizeInWord=scnr.next(); printGroupSize(sizeOfGroup); printGroupSize(sizeInWord); } }arrow_forwardWrite a method called subLR take a String number and return an integer that is the subtraction of left part and right part of the numbers. If the number has odd number of digits, then we ignore the middle one. Examples: • subLR ("123456") should return -333. Because left part is 123 and right part is 456, thus 123 - 456 = -333 • subLR ("92834") should return 58. Because left part is 92 and right part is 34 (we ignore 8 because of odd number of digits), thus 92 - 34 = 58 • subLR ("-123") should return -4. Because left part is -1 and right part is 3 (we ignore 2 because of odd number of digits), thus -1 - 3 = -4 subLR ("-345020") should return -365. Because left part is -345 and right part is 020, thus -345 - 20 = -365arrow_forward
- Write a class called listOddNumbers that prints the below picture. (Note: there is a single space between each number). Please show your code and copy and paste your console with the finished result.arrow_forwardPlease read the instructions carefully and keep in mind of the bolded phrases. You are NOT ALLOWED to use HashSet Create a project in NetBeans and name the project Hw06. The class will contain the following static methods: reverseS – A method that displays a string reversely on the console using the following signature: publicstaticvoidreverseS(Strings) printSub1 – print all substrings of a string (duplicated substrings are allowed, but loops are not allowed). The method signature: public static void printSub1(String s) printSub2 – print all substrings of a string (duplicated substrings are not allowed, but loops are allowed). The method signature: public static void printSub2(String s) Note: All methods should be RECURSIVE. Any predefined classes that are based on Set are not allowed. In the main method, read a string from the user and output the reversed string and substrings to the screen: Sample Run: Please input a string: abcdThe reversed string: dcbaThe substrings…arrow_forwardAdd another public method dblValue() to your Fraction class which returns the double precision approximation value of the fraction. That is, the floating point result of actually dividing numerator by denominator. N.B. this method does not do any display itself, but can be called by a client program to be used in an output statement. Eg: if a client has a fraction frac that represents 1 / 2, then a method call to frac.dblValue() should return the double number 0.5. Use your client program to test this functionality; i.e. provide an output statement to display the double value of a fractionhere are my codes /** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/package lab4; /**** @author engko*/public class Fraction {//Define the class Fraction// declaring instance variablesString res;private int num, denom; // default constructor to initialize instance…arrow_forward
- In intellij Create a method which takes two int parameters and swaps them. Print the values before and after swapping. (Example: ‘before swap: x = 5, y = 10; after swap: x=10, y=5). arrow_forwardIn this assignment you will demonstrate your knowledge of debugging by fixing the errors you find in the program below. Fix the code, and paste it in this document, along with the list of the problems you fixed.This example allows the user to display the string for the day of the week. For example, if the user passed the integer 1, the method will return the string Sunday. If the user passed the integer 2, the method will return Monday. This code has both syntax errors and logic errors. Hint: There are two logic errors to find and fix (in addition to the syntax errors).Inport daysAndDates.DaysOfWeek;public class TestDaysOfWeek {public static void main(String[] args) {System.out.println("Days Of week: ");for (int i = 0;i < 8;i++) {System.out.println("Number: " + i + "\tDay Of Week: " + DaysOfWeek.DayOfWeekStr(i) )}}}package daysAndDatespublic class DaysOfWeek {public static String DayOfWeekStr(int NumberOfDay) {String dayStr = ""switch (NumberOfDay) {case 1:dayStr =…arrow_forwardWrite a program in Java called StringIndex. Create a method called printIndex that passes your fullname as a parameter. Method should print each character of the String along with the index. For example, if String parameter passed is “Kimberly”, the program should print: 0: K 1: I 2: m 3: b 4: e 5: r 6: l 7: yarrow_forward
- Write a method that takes a RegularPolygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclusive, and sets its side length to a random decimal number greater than or equal to 5 and less than 12. Use Math.random() to generate random numbers. This method must be called randomize() and it must take an RegularPolygon parameter. You can call your method in the program's main method so you can test whether it works, but you must remove or comment out the main method before checking your code for a score. You will also need to make sure you do not remove the import statement "import testing.Math" as this is required to check your code for a score.arrow_forwardImage one is my code, I wanted to make some change to the blue part's code. The code I written in red(see image 1) is the method to check that an integer has exactly 5 digits is provided for you (fiveDigits). You just need to call it appropriately in your code(the part in blue square)! Notice that the fiveDigits method returns a boolean - think carefully about how you should use this return type to reprompt the user until they enter a valid zip code. And I want the same output be like (see image 2) for the invalid zip code part: I should only reprompt the user with the message "Invalid zip-code, enter valid zip-code: " until they enter a valid zip code. Similarly, if the user enters an invalid pain level, you should reprompt the user with the message "Invalid pain level, enter valid pain level (1-10): " until they enter a valid pain level. For example(image2)arrow_forward
arrow_back_ios
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