Question
inside a class named lab 4, write methods as follows: 1. a method named valueCheck that accepts a parameter int named value and, using a
inside a class named lab 4, write methods as follows:
1. a method named valueCheck that accepts a parameter int named value and, using a switch statement, displays text 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 parameter String objects named string1 and string2 and returns true if their text is identical and false otherwise
3. a method named sameObject that accepts two Objects as parameters and returns true if they are the same object and false otherwise (note that the Object class does not require any import statement)
4. a method named factorCheck that accepts a parameter int 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's indexOf() method. The method will accept as parameters two Strings, big and small. If the same text of small is contained in big, the method will return the index of the first character of small from its first appearance in big.
6. Write an extended version of String's indexOf() method. The method will accept as parameters two Strings, big and small, and two ints, start and end. Like 3) above, this method will search big for matching text with the String small and return the index of the first character of small from its first appearance in big. However, in this case the search will cover not the entire String big but the match must begin at or after index start and end at or before index end.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started