1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lelu [443]
3 years ago
11

Fill in the code to complete the following method for checking whether a string is a palindrome. public static boolean isPalindr

ome(String s) { if (s.length() <= 1) // Base case return true; else if ________ return false; else return isPalindrome(s.substring(1, s.length() - 1)); }
Computers and Technology
1 answer:
Ilia_Sergeevich [38]3 years ago
4 0

Answer:

(s.charAt(0) != s.charAt(s.length()-1))

Explanation:

public class Palindrome

{

public static void main(String[] args) {

   

    System.out.println(isPalindrome("car"));

    System.out.println(isPalindrome("carac"));

 

}

   public static boolean isPalindrome(String s) {

       if (s.length() <= 1)

           return true;

       else if (s.charAt(0) != s.charAt(s.length()-1))

           return false;

       else

           return isPalindrome(s.substring(1, s.length() - 1));

   }

}

You may see the whole code above with two test scenarios.

The part that needs to be filled is the base case that if the character at position 0 is not equal to the character at the last position in the string, that means the string is not a palindrome. (If this condition meets, it checks for the second and the one before the last position, and keeps checking)

You might be interested in
Define a function below called increase_elements_by_x, which takes two arguments - a list of numbers and a single positive numbe
zubka84 [21]

Answer:

function

increase_elements_by_x (list, x)

{

 var tplist = [];

 for (i = 0; i < list.length; i++)

   {

     tplist[i] = list[i] + x;

   print (tplist[i])}

 return tplist;

}

var list =[1, 3, 5];

var copyList;

var x = 3;

copyList = increase_elements_by_x (list, x);

print (copyList);

Explanation:

Create a list named list with initial data 1,3,5.

Create a function name increase_elements_by_x  which takes list and number as argument.Create empty list tplist. Loop through list, for ever index add x to list[index] and save to an empty list tplist. After loop is exited return tplist.

create a variable copylist and set it to increase_elements_by_x. Value returned by increase_elements_by_x  will be saved in copylist. print copy list to see content of copy list.

5 0
4 years ago
Vitamins and minerals dissolve easily in water.True or false?
noname [10]
True vitamins and minerals dissolves in water
8 0
3 years ago
Alex, a web designer, is assigned the task of creating a mobile device-friendly website for a leading fashion outlet called AllS
Katyanochek1 [597]

Answer: Pulldown menus

Explanation:

Pulldown menus refer to the graphical control element, that is identical to a list box, which enables user to be bake to select one value from a list.

They're regarded as the menu of options that will appear when an item is selected with a mouse. In this case, the item that the user selected will show at the top of the display screen, while the menu appears will show below it.

Therefore, Alex should use the pulldown menus to hide the long list of hypertext links so that it appears only in response to a tap of a major heading in the navigation list.

6 0
3 years ago
Skylar is viewing her personal and business calendar in a side-by-side fashion, but she would like to view a single calendar tha
pogonyaev

Answer:

The solution for the current situation in which Skylar is viewing her personal and business calendar in a side-by-side fashion, but she would like to view a single calendar that has appointments and meetings from both personal and business. is:

Configure the Overlay option.

Explanation:

The reasons behind this answer are that in the first place, creating another calendar is too much work. In the second place, the share of the calendars is not going to help her because that would only allow someone else to watch her calendars. However, using the overlay option will allow her to mix them and create one calendar with all her information.

8 0
4 years ago
Jennine has a table that she has created in Word. She has removed all borders inside the table, but now she wants a box around t
Crazy boy [7]

Answer:

The steps to create table, hide boarder and show border around the whole table is given below.

Explanation:

<u>1. Create Table</u>

  1. Click on insert Tab
  2. In insert tab, Click on Table
  3. Select No. of row and columns to create the table

<u>2. Hiding Boarders</u>

  1. Click on Design Tab
  2. In table style section Choose the layout that have no boarder

<u>3. Add boarder Around table</u>

  1. Click on Design Tab
  2. Select whole table by clicking on Plus sign on the top right corner of table
  3. Click on arrow of boarders button in Boarders section in design tab
  4. Select the "outside boarder" option from the list

<em>By following above mentioned steps, jennnine can draw a boarder around the table to distinguish it from rest of the document.</em>

8 0
4 years ago
Other questions:
  • Which of the following is an advantage of algorithmic thinking? Select all that apply.
    6·1 answer
  • The design activity key question, "how will this system interact with other systems..." is part of which design activity?​
    7·1 answer
  • Write an expression whose value is the arithmetic sum of the int associated with x, and the all-digit str associated with s. (hi
    9·1 answer
  • A client has an issue with large files taking a long time to open or save. As time goes by, the issue worsens. The client has hu
    8·1 answer
  • Computer programs and games are called what?
    13·1 answer
  • What are some effective methods for scrolling? Check all that apply.
    6·1 answer
  • Why is fluency in information technology becoming increasingly important for many college majors?
    6·1 answer
  • Explain the different type of shift register counter ​
    14·1 answer
  • Topic: Graphs.1.) Bob loves foreign languages and wants to plan his courseschedule for the following years. He is interested in
    8·1 answer
  • The batteries on electric vehicles are recharged using electricity from either a wall socket or dedicated charging unit.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!