Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Base code: Note: base code file is attached to help you get started! - Change code file name and class line from FunWithStringsBaseCode to FunWithStringsYourUHUsername

image text in transcribed

Base code:

image text in transcribed

Note: base code file is attached to help you get started! - Change code file name and class line from FunWithStringsBaseCode to FunWithStringsYourUHUsername - Write a main method that: - Asks for and reads in three Strings from the user. - Saves these as three String variables. - Send the Strings to a static method (averageStrings) which calculates their lengths and averages them. - Send the Strings to another static method (replaceChars) which does some changes to Strings - Finally prints out "Good bye" and ends. - Write a static method called averageStrings. - This method will take in three Strings as parameters - It should have a header line: public static void averagestrings(String s1, String s2, String 53) \{ - Inside this method, calculate the length of each String using the String method String.length(). The values should be saved in three variables. - Then the method should print out three lines like the following with the 's replaced by the actual strings and lengths: The first string you entered is: , it is characters long. The second string you entered is: it is characters long. The third string you entered is: , it is characters long. - Then the method should calculate the average of the length of the three Strings. - Be careful with types here! The length method returns int numbers, but the average length should be a double (since the total of the lengths may not be divisible by 3 ) - This means you may need to employ "conversion by assignment" or "typecasting" to make the division result be a double. - Finally the method should print out : The average length of your Strings is: characters. again the should be your actual average) - Write a second static method called replaceChars that takes in three strings as parameters - This method will have a header line: public static void replaceChars(String s1, String 52 , String s3) \{ - The method should use the String.replace(char, char) method to: - Replace all the 'e' characters in the first String with 'o' - Replace all the ' a ' characters in the second String with 'i' - Replace all the ' s ' characters in the third String with ' z ' - Then it should print out three lines like this: The changed first string: The changed second String: The changed third String: Where 's are the Strings with their characters replaced - Sometimes nothing will change because those letters weren't in the users Strings, that is fine

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

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions