Related Questions

Online Tutors To Help You

Online Tutors To Help You

Online Tutors To Help You

Online Tutors To Help You

Online Tutors To Help You

Online Tutors To Help You

Online Tutors To Help You

Posted in Computers and technology

I have a couple of questions on java for my homework 21229 Assume the availability of a method named makeLine that can be passed a non-negative integer n and a character c and return a String consisting of n identical characters that are all equal to c. Write a method named printTriangle that receives two integer parameters n andk. If n is negative the method does nothing. If n happens to be an even number, its value is raised to the next odd number (e.g. 4–>5). Then, when k has the value zero, the method prints a SYMMETRIC triangle of O’s (the capital letter O) as follows: first a line of n O, followed by a line of n-2 O’s (indented by one space), and then a line of n-4 O’s (indented by two spaces), and so on. For example, if the method received 5,0 (or 4,0) it would print: OOOOO OOO O Note: in the above output , the first line contains 0 spaces before the first O, the next line 1 space, and so on. Note: These instructions state what the method does when k is zero, but it is up to you, the programmer, to determine what it does when k is not zero and use it for your advantage. The method must not use a loop of any kind (for, while, do-while) to accomplish its job. The method should invoke makeLine to accomplish the task of creating Strings of varying lengths. 20861 A palindrome is a string that reads the same forwards or backwards; for example dad, mom, deed (i.e., reversing a palindrome produces the same string ). Write a recursive, boolean -valued method , isPalindrome that accepts a string and returns whether the string is a palindrome. A string , s, is a palindrome if: s is the empty string or s consists of a single letter (which reads the same back or forward), or the first and last characters of s are the same, and the rest of the string (i.e., the second through next-to-last characters ) form a palindrome. 20864 A ‘array palindrome’ is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are same when scanned forward or backward) Write a recursive, boolean -valued method , isPalindrome, that accepts an integer -valued array , and a pair ofintegers representing the starting and ending indexes of the portion of the array to be tested for being a palindrome. The function returnswhether that portion of the array is a palindrome. An array is a palindrome if: the array is empty (0 elements ) or contains only one element (which therefore is the same when reversed), or the first and last elements of the array are the same, and the rest of the array (i.e., the second through next-to-last elements ) form a palindrome.

Please login to view the answer

Online Tutors To Help You

Online Tutors To Help You

Online Tutors To Help You