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
ollegr [7]
3 years ago
9

A file named 'input.txt' contains a list of words. Write a program that reads the content of the file one word at a time. Check

if the word is a palindrome. If the word is a palindrome write it at the output file Output'.
Computers and Technology
1 answer:
Margarita [4]3 years ago
3 0

Answer:

// here is code in java.

import java.io.*;

import java.util.Scanner;

class Main{  

    // function to check a word is palindrome or not

 private static boolean is_Palind(String str1)

 {

     // if length of String is 0 or 1

   if(str1.length() == 0 || str1.length() == 1)

   {

     return true;

   }

   else

   {

       // recursively check the word is palindrome or not

     if(str1.charAt(0) == str1.charAt(str1.length()-1))

     {

       return is_Palind(str1.substring(1,str1.length()-1));

     }

     

     else

     {

       return false;

     }

   }

 }

// driver function

 public static void main(String[] args)

 {// variable to store word

   String word;

   // BufferedWriter object

   BufferedWriter buff_w = null;

   // FileWriter object

   FileWriter file_w = null;

   // Scanner object

   Scanner sc = null;

   try

   {

       // read the input file name

     sc = new Scanner(new File("input.txt"));

     // output file

     file_w = new FileWriter("output.txt");

     // create a buffer in output file

     buff_w = new BufferedWriter(file_w);

     

     // read each word of input file

     while(sc.hasNext())

     {

       word = sc.next();

     // check word is palindrome or not

       if(is_Palind(word))

       {

           // if word is palindrome then write it in the output file

         buff_w.write(word);

         buff_w.write("\n");

       }

     }

     // close the buffer

     buff_w.close();

     // close the input file

     sc.close();

   }

   // if there is any file missing

   catch (FileNotFoundException e) {

     System.out.println("not able to read file:");

   }

   // catch other Exception

   catch (IOException e) {

     e.printStackTrace();

   }

 }

}

Explanation:

Create a scanner class object to read the word from "input.txt" file.Read a word  from input file and check if it is palindrome or not with the help of is_Palind() function.it will recursively check whether string is palindrome or not. If it is  palindrome then it will written in the output.txt file with the help of BufferedWriter  object. This will continue for all the word of input file.

Input.txt

hello world madam

level welcome

rotor redder

output.txt

madam

level

rotor

redder

You might be interested in
you manage a network that has multiple internal subnets. you connect a workstation to the 192.168.1.0/24 subnet. this workstatio
nydimaria [60]

Based on the configuration written below, the most likely cause of the problem is Incorrect subnet mask.

<h3>What is an Incorrect Subnet Mask?</h3>

The issue of an Incorrect Subnet Mask will take place if a network uses a subnet mask that is not theirs for its address class, and a client is still said to be configured with the same default subnet mask for the address class, and thus communication tend to fail to some closeby networks.

Therefore, Based on the configuration written below, the most likely cause of the problem is Incorrect subnet mask.

Learn more about subnet mask from

brainly.com/question/27418272

#SPJ1

See full question below

You manage a network that has multiple internal subnets. You connect a workstation to the 192.168.1.0/24 subnet.

This workstation can communicate with some hosts on the private network, but not with other hosts. You run ipconfig /all and see the following:

Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : mydomain.local Description . . . . . . . : Broadcom network adapter Physical Address. . . . . . : 00-AA-BB-CC-74-EF DHCP Enabled . . . . . . . : No Autoconfiguration Enabled. . . : Yes IPv4 Address . . . . . . . : 192.168.1.102(Preferred) Subnet Mask. . . . . . . . : 255.255.0.0 Default Gateway . . . . . . : 192.168.1.1 DNS Servers . . . . . . . : 192.168.1.20 192.168.1.27

What is the most likely cause of the problem?

8 0
1 year ago
Which domain refers to the equipment and data an organization uses to support its IT infrastructure. It includes hardware, opera
vovikov84 [41]

Answer:

D. System/Application Domain

Explanation:

A system or application domain is used by an organization to supports its IT infrastructure, holding all the business critical mission system, applications and data. All the resources of the company are contained in this domain, and is accessible by a member.

LAN to WAN domain links the company's infrastructure or local area network to a wide area network or the internet. The WAN domain simply holds publicly the data of an organisation, while remote access domain is meant for a small group of workers in the office or working from home.

8 0
3 years ago
Yuri, a medical assistant, has been asked to send an account of a patient's last office visit to another doctor's office. The te
g100num [7]
The internet,,

To let the other doctor know about specific details on the patient, and other excessive information.

Hope this helps!! :)
6 0
3 years ago
Read 2 more answers
Learning in a digital environment is also called [blank] learning.
Dafna1 [17]

Answer:

The blank is online learning

4 0
2 years ago
Read 2 more answers
After inserting a video into your slide how can you test it
blagie [28]

Explanation:

How to insert video into PowerPoint

  1. Click on the slide you want, then go to Menu > Insert.
  2. In the top right corner, click Video > Video on My PC.
  3. Find the video you want to add and click “Insert”.
  4. Adjust the settings in the Video Format toolbar to make sure it plays the way you want.
7 0
3 years ago
Other questions:
  • Define the missing function. licenseNum is created as: (100000 * customID) + licenseYear. Sample output:
    10·2 answers
  • Given a computer running four types of instuctions, named classes A through D, calculate the execution time of a program that ha
    5·1 answer
  • If r is an instance of the above Person class and oddNum has been declared as a variable of type boolean, which of the following
    8·1 answer
  • What do i study to become a network engineer?
    11·1 answer
  • . Stress can affect not only your health, but also other aspectsof your
    15·1 answer
  • Select all the items that determine your preference for a concert ticket. a) band that is playing b) date of the concert c) pric
    7·1 answer
  • You view a portion of a document on the screen through a ____.
    6·1 answer
  • Why is charles babbage known as father of computer?​
    10·1 answer
  • Ergonomically designed workstations and equipment reduce stress-related injuries and improve the productivity and efficiency of
    13·2 answers
  • How do you make the "Colorize" feature in GIMP consistent if you cannot connect the different places? Brainliest if you also exp
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!