IDS 201 Lab Exercise 5 Within a class named LX5, write methods as follows: 1. a method...

80.2K

Verified Solution

Question

Programming

IDS 201 Lab Exercise 5

Within a class named LX5, write methods as follows:

1. a method named valueCheck that accepts a parameterint named value and, using a switch statement, displaystext output as follows:

  • if value is 4 or greater: \"LOTS\"
  • if value equals 3: \"three\"
  • if value equals 2: \"two\"
  • if value equals 1: \"one\"
  • if value equals 0: \"zero\"
  • if value is negative: \"NEGATIVE\"

2. a method named textMatch that accepts two parameterString objects named string1 and string2 andreturns true if their text is identical and false otherwise

3. a method named sameObject that accepts two Objectsas parameters and returns true if they are the same object andfalse otherwise (note that the Object class does not require anyimport statement)

4. a method named factorCheck that accepts a parameterint named value and returns values as follows:

  • if value is greater than 49 or less than 1, return-1
  • if value equals 1, return 0
  • if value is evenly divisible by 7, return 7
  • if value is evenly divisible by 5, return 5
  • if value is evenly divisible by 3, return 3
  • if value is evenly divisible by 2, return 2
  • if none of the above are true, return 1

5. Write an equivalent version of String'sindexOf() method. The method will accept as parameters twoStrings, big and small. If the same text ofsmall is contained in big, the method will returnthe index of the first character of small from its firstappearance in big.

6. Write an extended version of String'sindexOf() method. The method will accept as parameters twoStrings, big and small, and two ints,start and end. Like 3) above, this method willsearch big for matching text with the Stringsmall and return the index of the first character ofsmall from its first appearance in big. However,in this case the search will cover not the entire Stringbig but the match must begin at or after indexstart and end at or before index end.

Answer & Explanation Solved by verified expert
3.9 Ratings (512 Votes)
Lab Exercise 5 Java code Lab Exercise 5 public class LX5 Part 1 public void valueCheckint value switch value case 0 Systemoutprintlnzero break case 1    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students