Write a main method that reads in a single string

Assignment Help JAVA Programming
Reference no: EM13886170

PART A: TEXT TRIANGLE

Write a method that uses recursion to print an input string in the shape of a triangle, where the legs of the triangle are the first and last letters of the string and the base is the complete string; the contents are made up of the letters in between.

For example, given the string "abcdefghij", the corresponding text triangle looks like this:

    aj
   abij
  abchij
 abcdghij
abcdefghij

If there are an odd number of letters in the string, the first line will only have one character (use the first letter); "abcdefghi" generates:
     a
    abi
   abchi
  abcdghi
 abcdefghi

You should write a method called trianglePrint (Strings) that uses recursion to print s as a text triangle. Note that this method does not have enough parameters to do the job, it will need to call another method to solve the problem recursively.

Since your answer is recursive, there should be no loops anywhere in your program. You may want to write more than one recursive method (the triangle printer, and a helper method).

Write a main method that reads in a single string and calls trianglePrint with that string.

Hand in your Java source code, and the output generated (text triangles) for the following two strings (without the quotes): "disestablishmentarianism" and "+- ! '# =-= #* ! -+" (note the five spaces in the second one).

PART B: ORDER UP, THE LAST TIME

Once you've done part A, do it again, except replace the Ar rayLi st with your own linked list implementation. Do it any way you like, as long as the data gets stored in a linked list and stays there (that is, you're not allowed to copy it to or from an array or array list, for sorting or any other purposes).

Reference no: EM13886170

Questions Cloud

What would be the average velocity : A parabolic profile is desired in 20-C air as it passes between two parallel plates that are 80 mm apart in a university laboratory. If the Reynolds number Vh=n ¼ 1500, how long would the channel need to be to observe a fully developed flow, i.e.,..
Is the laminar flow assumption reasonable : A parabolic velocity profile is desired at the end of a 10-m-long, 8-mm-diameter tube attached to a tank filled with 20-C water. An experiment is run during which 60 L is collected in 90 min. Is the laminar flow assumption reasonable? If so, would..
Write program in java that solves system of linear equations : Write a program in java that solves system of linear equations. Users should be able to input the number of variables.
Explain access control methods and attacks : Explain access control methods and attacks
Write a main method that reads in a single string : Write a main method that reads in a single string and calls trianglePrint with that string. Write a method that uses recursion to print an input string in the shape of a triangle
Is the flow laminar or turbulent as it leaves the opening : The Red Cedar River flows placidly through MSU's campus at a depth of 80 cm. A leaf is observed to travel about 1 m in 4 s. Decide if the flow is laminar or turbulent. Make any assumptions needed.
Material or immaterial to the financial statements : The fraud was not detected by the external auditors.
The size ofthe character array holding your filename : How to express for code "THE SIZE OF THE CHARACTER ARRAY HOLDING YOUR FILENAME >=1024 (or use strings), we need to use long file names when grading your code."
Write one page about e-id verification topic : Write one page about E-Id verification topic - IEEE Spectrum IEEE Communications Magazine IEEE Network Magazine IEEE Personal Communications Magazine Communications of the ACM Sources.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java application to permit user to enter ten numbers

Write down Java application which permits a user to enter 10 numbers (double precision) into the array and then sorts and displays numbers from lowest to highest.

  1 gqueuea queue is an ordered collection of items in which

1 gqueuea queue is an ordered collection of items in which the removal of items is restricted to the fifo rst in rst

  How many bits are needed to represent the index size

How many bits are needed to represent the index size - what would be the index size if 8-way set associative cache were used with the same capacity and block size?

  Determine the length of a string

Determine the length of a string. The first version should use array subscripting, and the second version should use pointer arithmetic

  Assignment on java applets and activex controls

Go online and search for information about security threats posed by Java applets and ActiveX controls. Note that most of these programs are small in size and downloaded onto computers over the Internet.

  Write a program to simulate the behavior of the philosophers

Write a program to simulate the behavior of the philosophers, where each philosopher is a thread and the chopsticks are shared objects.

  What is a generic subprogram in java

How do you describe as a type in C++ a pointer to a function that takes two ints as arguments and returns a double. What is a generic subprogram in Java. What are its advantages

  How are data structures managed and organized in language

How are data structures managed and organized in this language. How does the management or syntax of data structures in this language differ from how data structures are handled in other language

  Write a java application that prompts the user for input

Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (these are two separate prompts for input values).

  How do you manage cookies in applet-servlet communication

When you communicate with a servlet from an Applet or an application, how can you ensure that the session information is preserved? That is, how do you manage cookies in applet-servlet communication?

  Write a method called hash midpoint

Write a method called hasMidpoint that accepts three integers as parameters and returns 'true' if one of the integers is the midpoint between the other two integers; that is to is if one integer is exactly between the two others. The method should re..

  What will unboxing do with null values

Java Question: Whatwill unboxing do with null values?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd