Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this practice question. Please include scanner for each task and inline comments throughout the code thank you. Please dontt use answers

I need help with this practice question. Please include scanner for each task and inline comments throughout the code thank you. Please dontt use answers already on Chegg website

- Amar

The question needs to be done in Java

Use a scanner to collect user inputs for each task and include thorough inline comments.

(StringTools.java, StringToolsTester.java) Write a class of static methods that accomplish the following tasks. In all cases do not look for built-in methods that accomplish the task, use loops as well as String and Character methods to get the tasks done.

reverse(String s) : String

-take a String as an argument and return the String reversed. Eg. Hello would be returned as olleH.

binaryToDecimal(String s) : int

-take a String as an argument and return the decimal equivalent as an integer. If any of the characters are neither zero nor one return null. Eg. 1000 would return 8. 10001 would return 17. 111111 would return 63. 111112 would return -1. (because its not valid) 100001.1 would return -1. (because its not valid)

initials(String s) : String

-take a String as an argument and return a properly initialized and capitalized name. If the String does not contain exactly three names return null. Eg. James tiBeriUs kiRK would return J. T. Kirk. jean luc picard would return J. L. Picard. KyLE HouStON would return null.

mostFrequent(String s) : char

-take a String and return the Character that occurs most frequently. In the event of a tie, return the last character that was checked in the tie.

replaceSubString(String s1, String s2, String s3) : String

-take three Strings as arguments. The first String is the users text. The second String is a pattern to look for. Make all Strings lowercase in the method to facilitate search and replace. The third String is a pattern to replace the second String with. Eg: the dog jumped over the fence as the first String, the as the second and that as the third. Returned String is that dog jumped over that fence.

Write a tester class that shows off all of your methods. Be sure that errors (input that results in null) are handled properly. (remember, you can test for null)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions