Question

In java, write a program with a recursive method which asks the user for a text...

In java, write a program with a recursive method which asks the user for a text file (verifying that the text file exists and is readable) and opens the file and for each word in the file determines if the word only contains characters and determines if the word is alpha opposite. Now what I mean by alpha opposite is that each letter is the word is opposite from the other letter in the alphabet. For example take the word "wizard." Its letters can be grouped (A and Z, D and W, I and R) that are opposite each other in the alphabet. That is A and Z are at opposite ends and etc. After determining if the word is alpha opposite, print out all the alpha opposite words in the file.

Requirements:

* Get a copy of the word as an array using toCharArray( )

* Sort the array using Arrays.sort( )

* Turn the sorted array back into a string using the String( char [ ] ) constructor.

* Pass the new sorted String to aplhaOpp (below) and decide whether it is or is not of the correct form.

alphaOpp Outline:

Boolean alphaOpp( String S ) {

   if length of S is 0 then return true; // we have checked entire string!

    Else if the first letter of the string is not the opposite of the last letter then return False.

    If we have not returned, then make the following recursive call but strip off the first and last characters!!! (HINT: use the substring( ) method defined for Java Strings).

alphaOpp( S.substring(1,S.length()-1)

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
In java, write a program with a recursive method which asks the user for a text...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • JAVA Code: Complete the program that reads from a text file and counts the occurrence of...

    JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...

  • I need eclipse code for : Write a program that analyzes text written in the console...

    I need eclipse code for : Write a program that analyzes text written in the console by counting the number of times each of the 26 letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example, both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once...

  • java programming Problem 2 (25 points) Counting Character Frequency. Write a program to analyze a text...

    java programming Problem 2 (25 points) Counting Character Frequency. Write a program to analyze a text file (a novel or a report, or just a sequence of letters or symbols), by reading the file into a byte array, convert to a string, and then scan the string letter by letter to count the frequencies of all unique characters in the text, after that, the letters with frequencies greater than 0 and the frequencies are reported side by side. All members...

  • In java write a command-line program that helps to decrypt a message that has been encrypted...

    In java write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1. Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case) are encrypted – a constant number, the shift, is added to the ASCII value of each letter and when letters are shifted beyond ‘z’ or ‘Z’ they are wrapped around (e.g. “Crazy?” becomes “Etcba?” when shifted by 2). When your...

  • Write a C program to run on ocelot to read a text file and print it...

    Write a C program to run on ocelot to read a text file and print it to the display. It should optionally find the count of the number of words in the file, and/or find the number of occurrences of a substring, and/or take all the words in the string and sort them lexicographically (ASCII order). You must use getopt to parse the command line. There is no user input while this program is running. Usage: mywords [-cs] [-f substring]...

  • JAVA Write a program which will read a text file into an ArrayList of Strings. Note...

    JAVA Write a program which will read a text file into an ArrayList of Strings. Note that the given data file (i.e., “sortedStrings.txt”) contains the words already sorted for your convenience. • Read a search key word (i.e., string) from the keyboard and use sequential and binary searches to check to see if the string is present as the instance of ArraryList. • Refer to “SearchInt.java” (given in “SearchString.zip”) and the following UML diagram for the details of required program...

  • Write a program named text_indexing.c that does the following: Reads text and stores it as one...

    Write a program named text_indexing.c that does the following: Reads text and stores it as one string called text. You can read from a file or from the user. (In my implementation, I read only one paragraph (up to new line) from the user. With this same code, I am able to read data from a file by using input redirection (executable < filename) when I run the program. See sample runs below). You can assume that the text will...

  • I need to write a program in java that reads a text file with a list...

    I need to write a program in java that reads a text file with a list of numbers and sorts them from least to greatest. This is the starter file. import java.util.*; import java.io.*; public class Lab3 { static final int INITIAL_CAPACITY = 5; public static void main( String args[] ) throws Exception { // ALWAYS TEST FOR REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length < 1 ) { System.out.println("\nusage: C:\\> java Lab3 L3input.txt\n"); System.exit(0); } //...

  • Please help me write this Java program. I had posted this question before, but got an...

    Please help me write this Java program. I had posted this question before, but got an answer that was totally wrong. We are using the latest version of Java8. Thank You! -------------------------------------------------------------------------------------- Write a Java program that can successfully DECRYPT a string inputted by the user which has been encrypted using a Caesar Cipher with a unknown shift value(key). You can use brute force to do a for loop through all the 26 shift values, however, your program should only...

  • Write two recursive methods that validate if the given string follows allowed patterns: isIdentifier method checks...

    Write two recursive methods that validate if the given string follows allowed patterns: isIdentifier method checks if the given string is a valid java identifier: must start with a letter, the subsequent characters must be letters or digits the length of a valid identifier must be at least one isDashDotCode method checks if the given string is a valid word in the following pattern: the characters must be dots or dashes the minimum length of a valid word is one...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT