Ask Java Expert


Home >> Java

Advancement Programming Assignment

No texts, notes, or internet access are allowed on this exam. Please read these instructions CAREFULLY and COMPLETELY before starting.
Your desktop contains a folder "W11APE". That directory contains the following items.

4 sub-folders titled: DataAbstraction, LinkedList, Recursion, and General.

Each of these folders contains a programming problem that you must address. The LinkedList folder and the Recursion folder contain subfolders. The subfolders in LinkedList are Part1 - addFirst, Part2 - addLast, Part3 - sort, and Part4 - remove. The subfolders in Recursion are Part1 - LinkedList and Part2 - GCD.

You do not need to work in any particular order, each of the folders can be completed independently from the others. If you are stuck, please free to try the other parts. NOTE: There are some .class files in the folders. ABSOLUTELY DO NOT delete or you will never get your code to compile. Leave the .class files intact.

Each folder has a file named output.txt file that illustrates the proper output your program should produce. There are also various source files and .class files in each folder. Do not modify or attempt to examine any of the .class files. Furthermore, only modify the source files you are told to for each part. Any other modifications will result in 0 points for that part.

All work you do on the exam must be done from inside this folder.

If you are unsure of anything you are being asked to do, seek help from the exam administrator.

Data Abstraction:

You are provided an abstract Stock class. You will need to write the compareTo method for the Stock class. Note: the Stock class implements Comparable. Sort Stocks based on the number of shares and then secondarily on the symbol.

Generate two subclasses (CommonStock.java and PreferredStock.java) that extend the superclass (Stock.java). The subclasses contain no unique fields.

These subclasses explicitly invoke the superclass's constructor and supply the concrete method to over-ride an abstract method that is within StockInterface. The abstract method header is public abstract double calcDividend(). For CommonStock there is no dividend. For PreferredStock the dividend is 1 cent for every share.

The Stock class contains a toString that returns a String containing the symbol, the number of shares and the price on separate lines. You will need to write a toString method for CommonStock and PreferredStock that calls the toString from Stock and then adds the dividend amount on a separate line. Don't worry about formatting the dividend amount.

Execution of the driver file should produce the output shown in the output file. NOTE: Do not attempt to modify Tester.java.

LinkedList:

There are 4 subfolders within the LinkedList Folder.

• Part 1 - addFirst: Write the clear(), addFirst(), and toString() methods for LinkedList.java. Do not attempt to modify Tester.java. Check the output file (output.txt) to see what should be produced from running the driver. Note: there are two fields (head and size) within the LinkedList class. The type passed into addFirst must be Comparable.

• Part 2 - addLast: Write the addLast() method for LinkedListA.java. Do not attempt to modify Tester.java. Do NOT delete LinkedList$Node.class, or LinkedList.class from the folder. Check the output file (output.txt) to see what should be produced from running the driver. The type passed into addLast must be Comparable.

• Part 3 - sort: Write a sort() method for LinkedListB.java. No Java API sort routine calls are allowed. Do not attempt to modify Tester.java. Do NOT delete any of the .class files from the folder. Check the output file (output.txt) to see what should be produced from running the driver.

• Part 4 - remove: Write the remove() method for LinkedListc.java. The method takes an int index as a parameter. It should remove the element at the specified position in this list. It should return the element previously at the specified position. If index is out of range then throw an IndexOutOfBoundsException. The first node in the list is index 0. Do NOT attempt to modify Tester.java. Do NOT delete any of the .class files from the folder. Check the output file (output.txt) to see what should be produced from running the driver.

Recursion:

There are 2 subfolders within the Recursion Folder

• Part 1 - LinkedList: Write the listReverse() method for LinkedListD.java. This method should print the contents of the list in REVERSE order. You must utilize recursion to accomplish this task. You are welcome to write a helper method to aid your recursion. Do NOT attempt to modify Tester.java. Do NOT delete any of the .class files from the folder. Check the output file (output.txt) to see what should be produced from running the driver.

• Part 2 - GCD: Write Euclid's GCD algorithm recursively. Pseudocode for the algorithm is provided at the top of the Tester file. Do NOT attempt to modify Tester.java. Do NOT delete any of the .class files from the folder. Check the output file (output.txt) to see what should be produced from running the driver. [For two non-negative numbers a and b, the gcd is a, when b is equal to 0; otherwise the gcd is recursively calculated with b and the result of a mod b]

General:

Modify the Tester.java file to:

• Connect a Scanner to the file name specified (openInputFile() method). Handle the FileNotFoundException exception with a try/catch and return a boolean success/failure flag.

• Connect a PrintStream to the file name specified: print an error message and exit the program on failure (openOutputFile() method). You must use a try/catch to handle the failure

• Disconnect from the input source, and disconnect from the output file (closeInputFile() and closeOutputFile() methods).

• Write a "read()" method to return the contents of the file as a String. The read method will read to end-of-file and then return the string. If the file is empty then return null. Don't forget to append a carriage return to each line.

• Write a "writeLine()" method to print a character string to the PrintStream object passed in.

Follow the directions given in the comments in IOException.java for more details.

Closing Notes:

• Please logoff your machine when done.
• Please return these instructions on your way out.

Attachment:- Recursion.zip

Java, Programming

  • Category:- Java
  • Reference No.:- M92328622
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As