QuestionQuestion

"Camel Acrostics"

For the first question of this assignment, you will design and write a program – in either Python 3 or Java (your choice) – that uses several recursive algorithms to compute a property that I am calling the "Camel Acrostic" of a list. The "Camel Acrostic" of a list of strings is the "word" that would be created if the elements of the list were written in "camel case" and then the capital letters were extracted and combined into a single string. (Please note that, for the purposes of this assignment, the term "camel case" refers to the capitalization of every word EXCEPT the first in the sequence.) As a clarifying example, the list of words:
["is", "tHis", "eXaMPLe", "SUFfIcIEntLY", "TELliNg"]
would be written in "camel case" as:
isThisExampleSufficientlyTelling
and would have a "Camel Acrostic" of:
TEST

The objective of this first question is to have you revisit the paradigm shift we discussed in the first lecture, where you as the designer focus your efforts, not upon describing "how" a result might be computed (as one might do in an imperative of procedural style), but instead upon "what" each of the necessary components is. Since we will (very shortly) be using recursive design exclusively, each of these definitions must be recursive in nature.

Your solution must meet the following requirements:
a) you must write two simple, non-recursive functions for changing uppercase letters to lowercase letters and lowercase letters into uppercase letters (respectively) … and if you use unnecessarily complex branching structures to do this, I will be very sad and you will be harshly penalized,
b) you must write a recursive function that will change the "case" of an argument string (written in "studly caps" i.e., with random capitalization) such that the return value is an equivalent string with ONLY the first letter capitalized; this function MUST use the function you wrote for requirement (a) above,
c) you must write a recursive function that will take a list of strings as an argument and create a single string in "camel case" (i.e., with an uppercase letter at the beginning of every word EXCEPT the first) as the return value; this function MUST use the function you wrote for requirement (b) above
d) you must write a recursive function that will take a string as an argument and retain and combine (in order) only the capitalized letters into a new string return value, and
e) you must write a simple interface for the user (used for testing your submission); this interface must permit the user to type a string, parse that string into a list of words, compute the "Camel Acrostic" (using the functions you wrote for requirements (c) and (d) above), display the resulting "word", and finally ask the user if they would like to continue (looping back to the beginning or terminating the program as required).

Please note that you must write your own functions for requirement (a); you cannot use built-in functions. Please also note that the looping control structure used for the interface mentioned in required (e) above must be the only looping control structure used in your entire program – the functions described in requirements (b), (c), and (d) must be recursive and cannot use looping control structures.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.ArrayList;
import java.util.Scanner;

public class CamelAcrostics {

    /**
    * a)you must write two simple, non-recursive functions for changing
    * uppercase letters to lowercase letters and lowercase letters into
    * uppercase letters (respectively) … and if you use unnecessarily complex
    * branching structures to do this, I will be very sad and you will be
    * harshly penalized,
    *
    */
    public static String toLowerCase(String str) {
       String result = "";
       for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (ch >= 'A' && ch <= 'Z') {
                ch = (char) (ch + ('a' - 'A'));
            }
            result += ch;
            //result += Character.toLowerCase(str.charAt(i));
       }
       return result;
    }

    public static String toUpperCase(String str) {
       String result = "";
       for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (ch >= 'a' && ch <= 'z') {...

By purchasing this solution you'll be able to access the following files:
Solution.java.

$64.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats