Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Submit a single java file, StringMethods.java Description: This assignment will

ID: 3530310 • Letter: S

Question


Submit a single java file, StringMethods.java


Description:


This assignment will give you practice with Strings and methods. Submit a single java file,
StringMethods.java. There are several methods that you have to write as listed below. Create them
in a single java file named StringMethods.java, create a main to test all the methods. Leave all the
tests in there to show that you have tested all cases.

1. Write a method named sameDashes that takes two strings as parameters and that returns
whether or not they have dashes in the same places (returning true if they do and false
otherwise). For example, below are four pairs of strings of equal length that have the same
pattern of dashes. Notice that the last pair has no dashes at all.


string1: "hi--there-you." "-15-389" "criminal-plan"
"abc"
string2: "12--(134)-7539" "-xy-zzy" "(206)555-1384"
"9.8"


To be considered a match, the strings must have exactly the same number of dashes in exactly
the same positions. The strings might be of different length. For example, the following calls
should each return true:


sameDashes("1st-has-more characters", "2nd-has-less")
sameDashes("1st-has-less", "2nd-has-more characters")


because the strings each have two dashes and they are in the same positions. But the following
calls should each return false because the longer string has a third dash where the shorter
string does not:


sameDashes("1st-has-more-characters", "2nd-has-less")
sameDashes("1st-has-less", "2nd-has-more-characters")


2. Write a method named numTWords that takes a String as a parameter and that returns the
number of words in the string that start with the letter t (upper or lowercase). By definition,
words are separated by one or more spaces. For example:


numTWords("are there lots of t words here?")


should return 2. Notice that words can contain punctuation marks. Any non-empty sequence of
non-space characters can be a word. There might be spaces at the beginning or end of the
String. For example:


numTWords(" how about trick-or-treaters, candy, and cats?")


should return 1. You may not construct any other objects to solve this problem (e.g., you can't
use a Scanner). You may assume that the string has no other whitespace characters such as
tabs or newline characters. Your method has to pay attention only to spaces to decide how
many words there are.




Explanation / Answer

USE GRAPHICAL USER INTERFACE gui And then for the first part read whole string one by one and loop the one in another one one for the length of first string and secong till the second string ends and match corresponding element if they have dashes at same place ...continue till the string ends and print theindex where the string get matched else return boolean false.... For the second part see read the charachters of string one by one using array...and whenever u get a blank space u know that u have got a word ...so store that in an array ....similarly store all such words and then one by one by looping see which of them start with t ...if it starts with a then count++; finally return count..... I hope that will help ...DO RATE 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote