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 program on roulette

Consider the game of Roulette, where players bet on the numbers 1 through 36 (as well as 0 and 00). A large wheel consisting all 38 of these numbers and a small ball is spun until the ball lands on one of these numbers at random.

  Implement an inheritance hierarchy based on the following

Implement an inheritance hierarchy based on the following specifications for Account class, Checking Account class, and Savings Account class Methods: processDeposit ( ) - accepts a single double parameter containing the deposit amount. Updates the ..

  How can i connect from an applet to a database on the server

1) How do I create an applet that accepts an unlimited number of parameters? 2) How can I connect from an applet to a database on the server?

  Write a program using bucket sort idea to create histograms

The input data are in an external file named election.txt. The first line is an integer N representing the number of candidates. The next N lines are the names of the canditates.

  Write a while loop that lets the user enter a number

1) Write a while loop that lets the user enter a number. The number should then be multiplied by 10, and stored in a variable called product. The loop should then iterate as long as product contains a value less than 100.

  Wa program that takes 10 values represent

Using a loop, write a program that takes 10 values represent in exam grades (between 0 and 100) from the keyboard and outputs the minimum value, maximum value, and average value of all the values entered.

  Method called wordlengths that accepts a scanner

Write a method called wordLengths that accepts a Scanner representing an input file as its argument. Your method should read from the given file.

  Using a linked implementation of graph write a method that

using a linked implementation of graph write a method that takes two nodes as input and returns true if joining an edge

  The program randomly generates the quiz question one by

the program randomly generates the quiz question one by one from a set of available questions on general knowledge

  Create an abstract employee class

We are going to create an abstract Employee class and an abstract calculatePay method. The abstract Employee class will prevent a programmer from creating an object based on Employee

  Write java programming to show number of credits for course

Write the java programming to solve following problem. We are given a student's marks in Calculus 1, CS1, and Physics 1 (each mark being between 0 and 100) also number of credits for each course.

  What are operator overloading rules?

What are operator overloading rules?

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