Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Within a class named LX4, write methods as follows: 1. A method named intMatch that accepts no parameters, returns void, and: Prompts the user to

Within a class named LX4, write methods as follows:

1. A method named intMatch that accepts no parameters, returns void, and:

  • Prompts the user to enter three integers, separated by space characters but on the same line
  • If any of the integer values are equal, prints the message "equal values found"
  • Otherwise, prints the message "all values different"

2. A method named stringMatch that accepts no parameters, returns void, and:

  • Prompts the user to enter three Strings, separated by space characters but on the same line
  • If any of the Strings have identical text, prints the message "matching Strings found"
  • Otherwise, prints the message "all Strings different"

3. A method named showSubstring that accepts no parameters, returns void, and:

  • Prompts the user to enter a text String
  • Prompts the user to enter a non-negative integer starting index. If the entered value is less than zero, the method will display an error message and then end.
  • Prompts the user to enter a non-negative integer ending index. If the entered value is not a valid index for the text String or less than the starting index, the method will display an error message and then end (by returning)
  • If the starting and ending indexes are valid (within the bounds of the text String, with the starting index less than or equal to the ending index), displays the substring with those starting and ending indexes.

For example, if the user entered the text String "abcdefg", the starting index 2, and the ending index 5, the method should display "cde".

4. A method named romanNumeral that accepts no parameters, returns void, and:

  • Prompts the user to enter an integer value between 1 and 6
  • Using a switch statement, prints the Roman numeral corresponding to the entered value (1: I, 2: II, 3: III, 4: IV, 5: V, or 6: VI)
  • If the user enters a number outside the range 1 to 6, prints an appropriate error message

5. A main method creating an LX4 object and calling its methods intMatch(), stringMatch(), showSubstring(), and romanNumeral()

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions