Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need the answer for lap questions. i do not need the code. this in java program Lab Report Questions: Define a static method and

i need the answer for lap questions. i do not need the code. this in java program

Lab Report Questions:

Define a static method and give when is it most appropriate to use a static methods?

Is it possible for a static method to call a non-static method?

Objective:

Write a program that creates a helper class called StringHelper. This class has methods not already built into strings, but should be because they are super useful.

First create a class called StringHelper which has the following static methods

meshStrings: This method takes in two strings via parameters, meshes them together, and returns the meshed strings. Meshing alternates the each character in the first string with every character in the next string. If there are not enough characters to fully mesh then the rest will be appended to the end. For instance if the two strings were harp and fiddle the returned string will be hfairdpdle.

replaceVowelsWithOodle: This method takes in one string via parameter, and returns the string with every vowel (a,e,i,o,u) replaced by the phrase oodle. For instance if the string is burrito then the returned string would be boodlerroodletoodle. Also case does not matter.

weight: Much like length returns the number of characters in a string, the weight gives the weight in kilograms. This method takes in a string and returns a double value corresponding to its weight. Everyone knows that a words weight is determined by each vowel (a,e,i,o,u) counting as 2.5 kilograms and each consonant as 3.4 kilograms.

Finally create a class called StringHelperTester

This class DOES HAVE a main method

Test each method multiple times to determine if they work.

Example Dialog:

Welcome to the String Helper Tester

Meshing harp with fiddle

hfairdpdle

Replacing vowels with oodle in the word burrito

Boodlerroodletoodle

The weight of the word taco is

11.8

Lab Report Questions:

Define a static method and give when is it most appropriate to use a static methods?

Is it possible for a static method to call a non-static method?

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

How can privacy of data be preserved in a database?

Answered: 1 week ago

Question

3. Contrast relational contexts in organizations

Answered: 1 week ago

Question

2. Describe ways in which organizational culture is communicated

Answered: 1 week ago

Question

1. Describe and compare approaches to managing an organization

Answered: 1 week ago