Java Homework Problems

This project was successfully completed by vano101 for $30 USD in a day.

Get free quotes for a project like this
Project Budget
$30 - $250 USD
Completed In
1 day
Total Bids
Project Description

I have two small Java homework problems that I need someone to help me with. These will not take long and the assignment is well defined. Once the job has been accepted, I will send you my attempt at the first one. I have finished the second one, but I need someone to check over it and add two methods.

1) Symbol Balancing:

Implement a class called It should take a the name of a java file as a command line argument. Read in the file and check to make sure that all { }'s, ( )'s, [ ]'s, " "'s, and /* */'s are properly balanced. Make sure to ignore characters within literal strings and comment blocks. You do not have to deal with single line comments (those that start with a //).

There are a number of error cases:

The file ends with one or more opening symbols missing their corresponding closing symbols.

There is a closing symbol without an opening symbol.

There is a mismatch between closing and opening symbols (for example: { [ } ] ).

Your program should output whether or not the symbols are all appropriately balanced. If they are not, indicate which error condition occurred and what symbol type caused the problem.

You will need to write your own stack class for this. It should be generic (in this particular case you will be pushing Character objects on it, but it should be capable of handling any object reference). Call your stack class: You may use [url removed, login to view] as an instance variable in your MyStack class, but in the implementation of your stack methods, you are only allowed to use its basic list operations, not the stack operations themselves (that is, do not use LinkedList's native push and pop methods).

Here is an example. You are given a java file with with the following contents:

public class Test {

public static final void main(String[ ) args) {

[url removed, login to view]("Hello.");



You would then run your program:

java SymbolBalance [url removed, login to view]

and the output should be something like:

Unbalanced! Symbol ) is mismatched.

Please be sure to include a test java file with your submission, call it [url removed, login to view] that illustrates one of the error conditions. To help you with testing, we've written a number of test input files that you can use with your program in the file: [url removed, login to view] in a new window.


Two Stack Queue : Build a queue out of two completely separate stacks, S1 and S2. Enqueue operations happen by pushing the data on to stack 1. Dequeue operations are completed with a pop from stack 2. Obviously you will have to find some way to get the input stack information over to the output stack. Your job is to figure out how and when to do that, using only push and pop operations.

Write a class TwoStackQueue that provides the Queue ADT (as specified in the [url removed, login to view] the documentView in a new window interface) using two stacks. Your class should explicitly implement the interface provided above. Since the interface is generic, your class should be as well. Provide all methods specified in the interface. Your class should not use any additional memory to store the data in the queue except for the two stacks. Use your stack implementation from programming problem 1.

Write a tester class with a main method to demonstrate that your TwoStackQueue works correctly (by enqueueing a number of objects and then dequeueing and printing them in the correct order). Call your tester class You can find a sample tester class in the file [url removed, login to view] the documentView in a new window. It is similar to the one that we will use to grade your submission. Your tester should try different examples, than the ones from this sample.

In a file called [url removed, login to view], discuss the big-O running time of the enqueue and dequeue operation for your queue implementation.

[url removed, login to view] file: Points for including the proper README.txt.

Completed by:
Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online