- Case StudyHelp.com
- Sample Questions
Assignment #1 (80 Points) – COSC 2336 – Dr. Leonard Brown Due: September 24, 2015 (at 11:59pm)
General Description There are two parts (I and II) to this assignment. Part I is not a programming assignment. Part II is.
Part I (20 points) Identify the base case and the general case of recursive solutions for each of the following programs Given a collection of n > 0 numbers, find their sum. Given a string of n > 0 characters, count the number of vowels. Given a route from Point A to Point B, where the route consists of a collection of roads with a given distance along each road, compute the total distance. Starting from the root directory of the C: drive, find the location of an input file. Given a maze where, at each step, you may move one space forward, one space left, or one space right (if those spaces are not blocked), find the exit.
Part II (60 points) Write a recursive program in Java that can interpret a fictional markup language. The input to the program will be a text file that contains text embedded with several markup tags. The output from the program will be a text file that contains the formatted resulting from the application of the markup tags.
The syntax of the markup language is very straightforward. Each command starts with a single dash (‐) in order to differentiate it from the actual text. Each command specifies a format that should be applied to the actual text until the command –END is encountered (preceded by a single dash). Note that multiple markup commands may be applied at the same time with the innermost markup applied first. Multiple markup commands may be terminated by a single –END command.
To illustrate the use of the markups, consider the following example input line. It contains several markup commands.
This -CAPS is –WHY –DOUBLE an –END example –EXPAND sentence -END.
Markup Definition Input Text Formatted Text ‐CAPS Capitalize text Apple APPLE ‐DOUBLE Append a copy of the text to itself Apple Apple Apple ‐EXPAND Put a single space between each pair of letters Apple A p p l e ‐WHY Replace each vowel by the letter y (maintaining case) Apple Ypply ‐END Stop applying the current format
Processing the markups in the input text would cause the following output to be generated. This IS YN YN example s e n t e n c e. Your program should read a text file containing several lines similar in format to the previous example.
Your program should produce a text file containing the correct output for the text.
As stated earlier, this program must use recursion. You should have a recursive method that accepts a string argument and returns a string argument. One approach to solving this problem is to tokenize the input string and print each token until one is encountered that starts with a dash. Process this token as a command that should be applied to the result obtained from processing all of the text until the next –END command.
You must provide comments describing the purpose of each logical section of your code. Remember that the purpose of commenting code is to improve program readability, so you should not provide a comment before each line of code that you write. When in doubt, it is usually better to “overcomment” code than to provide too little documentation.
Your recursive method must include a comment that clearly indicates the processing of the base case. In addition, you must include a header to your program that contains your name, class number, section number, semester, assignment number, date, and project description.
In addition, you must provide a header for each method that you write in your code. Each method header must describe the method’s purpose, its input, and its output. In addition, the format of your code must follow good programming principles as in your textbook(s). This means that you must use blank lines and indentation to arrange and/or separate logical sections of your code. You must also use meaningful variable names Since you are writing an object‐oriented program, you will also be evaluated on your design. Your program must use multiple classes. Within each class, the data values should be private, and the methods should be public.
Since the data values are private, you will need to create public accessor (get) and mutator (set) methods for each data value.
-WHY Recursion –CAPS is an –END –DOUBLE extremely –END powerful problem-solving –WHY –EXPAND technique. –END Problems that at –CAPS first appear –WHY to be quite difficult –END often have –DOUBLE simple –CAPS recursive –END solutions.
Rycyrsyyn YS YN extremely extremely powerful problem-solving t y c h n y q y y. Problems that at –CAPS FIRST APPEAR TY BY QYYTY DYFFYCYLT often have simple RECURSIVE simple RECURSIVE solutions.
Your program (Part II) will be graded based on the following criteria Implementation of Requirements 20 points Program Works Correctly 20 points Class Design 10 points Documentation 10 points
Submit your assignment through Blackboard. If your assignment contains multiple files, zip them into a single folder before submitting.
Points can be deducted from your assignment based on the quality of its presentation. Handwritten assignments will not be accepted.
To get assignment samples chat with our online assignment adviser (Chat with our 24 x 7 Online Agents).
Ask Your java Programming Assignment?
Check out our java Assignment Help Australia
Find Your Computer Science Assignment Experts