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
brilliants [131]
3 years ago
12

Write a void method called palindromeCheck that takes NO argument. The method should have functionality to check whether or not

the word is a palindrome and print to the screen all of the palindromes, one per line. Also, the last line of the output should have the message: "There are x palindromes out of y words provided by user" (where x is the number of palindrome words detected, and y is the total number of words entered by user). Hint: for this lab exercise you will need the following methods on String objects: length() gives the length of a string (that is, the number of characters it contains) and charAt(i) - gives the character at position i.
Computers and Technology
1 answer:
finlep [7]3 years ago
8 0

Answer:

Explanation:

import java.util.Scanner;

public class PalindromeCheck

{

public static void palindromeCheck()

{

String someWord=" ";

int count=0;

int total=0;

System.out.println("Ënter some words entered by whitespace");

Scanner keyboard =new Scanner(System.in);

String[] words=keyboard.nextLine().split(" ");

for(int i=0;i<words.length;i++)

{

boolean flag=true;

int l=words[i].length();

for(int j=0;j<=l/2;j++)

{

if(words[i].charAt(j)!=words[i].charAt(l-j-1))

{

flag=false;

break;

}

}

if(flag)

count++;

}

System.out.println("There are "+count+" palindromes out of "+words.length+" words");

keyboard.close();

}

public static void main(String[] args)

{

palindromeCheck();

}

}

Output

Ënter some words entered by whitespace

This is a malayalam.

There are 3 palindromes out of 4 words

You might be interested in
What is that black thing on my wall?
Darya [45]
I'm guessing your television if it's a flat screen
7 0
3 years ago
Which of the following statements is not true? Group of answer choices
Nesterboy [21]

Answer:

A

Explanation:

Option A is not true because a Boolean variable type can hold one of two values only that is  (true/True or false/False).

All the other options given in the question are correct because

  1. A variable declaration refers to specifying its type and name
  2. If string variables are assigned a numeric values which is legal provided the values are enclosed in quaotes( " "), trying to carryout a mathematical operation like addition will result in string concatenation.
  3. The Variable name I_Love_to_eat_pizza is legal because it contains no special characters, doesn't start with a number and its not a reserved word in any language
4 0
3 years ago
How will you be assigned with a mailbox with any OSP
Leona [35]

Answer:

Go to the File tab and click Options.

Click on the Mail menu at the left.

Click on the Signatures button to open the Signatures and Stationary window.

In the Email Signature tab, click New.

Type in a name for the New Signature such as Shared Mailbox Signature and click OK.

Explanation:

3 0
3 years ago
What is unique address in ICT​
iren2701 [21]

Answer:

IP Addressing.

Explanation:

It stands for Internet Protocol address. It is a unique address that identifies a computer on a network such as the Internet.

Hope this helped you!

4 0
3 years ago
Explain the process of creating a switch statement to replace an if-then-else statement in Java.
musickatia [10]

Answer:

The answer to this question is given in the explanation section.

Explanation:

Let look at an if the else statement

if (condition1) {

 //some code if condition 1 is true

} else if (condition2) {

 // some code if condition 2 is true

} else {

 // some code if condition 3 is true

}

No let look at switch statement

switch(expression) {

 case x:

   // code block

   break;

 case y:

   // code block

   break;

 default:

   // code block

Now let look at your answer.

if then else should be replaced with switch if conditions are fixed.

in the process of replacing

write your condition of if statement  in the case area of swatch

7 0
3 years ago
Other questions:
  • William is an amateur photographer who plans to create a portfolio to improve his career prospects. He wants to capture a mother
    6·1 answer
  • Devices used for viewing images from one computer to another over the internet
    6·1 answer
  • Each processor or core processes two threads at the same time is called _________.
    5·1 answer
  • The control programs managing computer hardware and software perform the _________ function to control and prioritize tasks perf
    8·1 answer
  • When you're working with a word processing document and you press the del key, what happens?
    5·1 answer
  • Which part of the Word application window should the user go to for the following activities?
    14·1 answer
  • SXXSSSSSSSSSZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
    14·1 answer
  • Lisa is developing a Web application using a framework and wants to include interactive elements using JavaScript. She decides t
    10·1 answer
  • List three ways you can help somone who is being cyber bullied instead of just being a bustander​
    7·2 answers
  • Consider the following method substringFound, which is intended to return true if a substring, key, is located at a specific ind
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!