Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need assistance with the following Java code Create a class named Ex4_1 , with the following static methods in it: A method displayRowOfCharacters that

I need assistance with the following Java code

Create a class named Ex4_1, with the following static methods in it:

A method displayRowOfCharacters that displays any given character the specified number of times on one line. For example, the call

displayRowOfCharacters('*', 5);

produces the line

*****

Implement this method using recursion.

A method, getInput, that asks the user for integer input that is between 1 and 10, inclusive. If the input is out of range, the method should recursively ask the user to enter a new input value.

A palindrome is a string that reads the same forward and backward. For example deed and level are palindromes. You did implement a similar method in exercise 3, however in this one you can assume that input string will only consist of lowercase letters, and that parameter won't be null. Implement a recursive method isPalindrome.

If n is positive integer in Java, n%10 is its rightmost digit and n/10 is the integer obtained by dropping the rightmost digit from n. Using these facts, write a recursive method, named displayDigits, that displays an integer n in decimal.

You need to use the template provided below

public class Ex4_1

{

public static void main(String... args)

{

displayDigits(12345); // displays 1.2.3.4.5.

}

public static void displayRowOfCharacters(char c, int n)

{

// Needs to be implemented

// You can assume n is positive, i.e., n>=1.

}

public static int getInput(Scanner keyboard)

{

// Needs to be implemented

}

public static boolean isPalindrome(String str)

{

// Needs to be implemented

}

public static void displayDigits(int n)

{

// Needs to be implemented

// You can assume n is positive, i.e., n>=1.

}

}

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions