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
Juliette [100K]
4 years ago
13

Write a method that checks whether the input string or a sentence (a string with spaces) is a palindrome or not. The method shou

ld be case insensitive and should ignore spaces. Write a test program that prompts the user to input a string and invokes this method. Some example runs are: Enter the input string: madam Input string madam is a palindrome Enter the input string: banana Input string banana is NOT a palindrome Enter the input string: Race Car Input string Race Car is a palindrome Enter the input string: Too HOT to hoot Input string Too HOT to hoot is a palindrome
Computers and Technology
1 answer:
AURORKA [14]4 years ago
5 0

Answer:

import java.util.Scanner;

public class Pallindrome {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter the input string: ");

       String word = in.nextLine();

       System.out.println(isPallindrome(word));

   }

   public static String isPallindrome(String word){

       String rev ="";

       int len = word.length();

       for ( int i = len - 1; i >= 0; i-- )

           rev = rev + word.charAt(i);

       if (word.equals(rev))

           return word+" is palindrome";

       else

           return word+ " is not palindrome";

   }

}

Explanation:

  • Create the method in Java to receive a String parameter
  • Using a for loop reverse the string
  • Use another for loop to compare the characters of the original string and the reversed string
  • If they are equal print palindrome
  • else print not palindrome
  • Within the main method prompt user for a sentence
  • Call the method and pass the sentence entered by user
You might be interested in
Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. Given a variable modelYear write a state
DerKrebs [107]

Answer:

((model years >=1995 && model years <= 1998) || (model years >= 2004 && model years <=2006 ) ? no recall= false : no recall = true;

Explanation:

8 0
3 years ago
What is the purpose of the .NET Framework Class Library? a. it provides pre-written code that can be used by .NET applications b
Burka [1]

Answer:

d. it specifies the data types that can be used by .NET applications.

Explanation:

The .NET Framework Class Library (FCL) makes the system functionality of the .NET Framework available because it contains interfaces, data types, various classes and so on.

It is also important to note that the FCL is integrated to the CLR or Common Language Runtime of .NET Framework which is responsible for code execution.

The Framework Class Library or FCL can be categorized broadly into three:

1.  Frameworks

2. Utility features in .NET, and

3. Wrappers around the Operating System (OS) functionality.

1. Frameworks: The FCL contains many frameworks aimed at the development of some applications. For instance, WPF or Windows Presentation Foundation is used to carry out a number of functions but majorly to render user interfaces.

2. Utility features in .NET: This contains a number of classes for use in the .NET framework, examples of these classes include: dictionary, queue, stack, list and so on. Additionally, it contains classes for different manipulations, for example, for handling regular expressions the Regex class is available for use.

3. Wrappers around the Operating System (OS) functionality: Contained in the Framework Class Library are wrappers that are present at the root functionality of the Windows OS. For instance, classes to handle I/O, network features, file system as so on.

8 0
3 years ago
Identifying Characters
alina1380 [7]
The answer is d I just took the test
5 0
3 years ago
Read 2 more answers
What objective behaves like a high level array
zavuch27 [327]

Answer:

C.Vector

Explanation:

Vector is a high level array used in C++.It has the capability of resizing itself when it gets full.it has many functions that increases it's functionality like size(),begin(),end(),erase(),clear(),push_back(),pop_back() and many more and we store any kind of data type in the vector.

syntax for declaring a vector:-

vector<data type> vector name.

8 0
3 years ago
Given a line of text as input, output the number of characters excluding spaces, periods, or commas. If the input is:
enot [183]

In python 3.8:

print(len([x for x in input("Enter your text: ") if x not in "., "]))

I hope this helps!

3 0
3 years ago
Other questions:
  • What do you think is the most effective way to ensure that code adheres to good coding standards? (1 correct answer)
    5·2 answers
  • 12.
    9·1 answer
  • The headings that appear on the Ribbon, such as File, Home, and Insert, are called:
    5·1 answer
  • What can you search on Microsoft Word or Powerpoint Clipart or Google (Clip art) to find more pictures like the ones below but w
    7·1 answer
  • Assume that a file containing a series of integers is named numbers.dat and exists on the computer's disk. design a programt hat
    15·2 answers
  • Which is the fastest CPU and why?
    5·1 answer
  • Use the drop-down menu to complete the sentences about the benefits of flowcharts.
    5·1 answer
  • Part1) Given 3 integers, output their average and their product, using integer arithmetic.
    12·1 answer
  • Type the correct answer in the box.
    15·1 answer
  • How to transfer bookmarks from one computer to another.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!