Solved

Modifications in program to get the correct desired output

Posted on 2008-10-23
3
198 Views
Last Modified: 2013-11-23
Hello,
In order to follow this question you will necessarily need to see the files being attached.

The problem
The original code and output are shown in the files under Lab4Original.zip
The modified code and resulting output are shown under Lab4dVersion1.zip

Description of the problem
The desired output should be ONLY the list of words sorted in alphabetical order (a to z). Case sensitivity and special characters should not matter.  

The given files are cisio.java, Index4.java, lab4d.java, Token.java and Node .java.
I have changed the extension on all of these to .txt.

The input file is lab4d3.txt. The given output file is Output_Given.txt. It is what you get when you run the given code.  

In order to get the desired output of alphabetically sorted words all I did was the following

1)Added an insert(t) method that inserts strings in a sorted manner in the Index4.java file.
2)Called this insert(t) method from the lab4d.java (main) file.

I did not modify anything else this far. I realize that there are things that are needed to be modified so that

1)there is no paragraph with lines numbers in the output and
2)I get the words in a more correctly sorted fashion than I have them now in my Version1 of the output.

You can see the results of these changes in Output_Version1.txt. This however is not the fully correct desired output. I have got only partial results.

Please note that you can see the changes I have made to the original files under the Lab4Verion1.zip folder. Once again I have had to rename Index4.java to Index4.txt and lab4d.java to lab4.txt. All other needed files you need to run in order to get the output that I am getting now are the same as in the original. These have not been changed, so I did not re-include them in this folder.
So if you can please examine this at leisure and get back to me as to what changes are needed in order to get the desired output(which is ONLY the alaphabetically list of words (the special characters and case do not matter), I will be grateful. In the meanwhile I am trying to solve this myself.

If anything is not clear please ask the question and I will clarify

Thanks,

Ohjava

Lab4Original.zip
Lab4dVersion1.zip
0
Comment
Question by:ohjava
  • 3
3 Comments
 

Author Comment

by:ohjava
ID: 22791838
Increased the points as solving this question takes some work - have to open files and read them and examine output etc. Please take your time to examine question carefully.
0
 

Accepted Solution

by:
ohjava earned 0 total points
ID: 22792686
Hello,
This is to let you know that I have made progress in solving the above question to a large extent.  
Once again it will be necessary to examine the files.

Compared with the code that was given at the start of this problem, the files that have been modified are Index4.java, Token.java and lab4d.java.

Now the output is as is shown in Output_Version2.txt file.

The only problem is the very first line. It is not supposed to be there. Can anyone find out why it is showing up? But for this I think I have got the output in the form that was desired. Please see original files and modified files attached (Version2) to see where I have made the changes.

Please note that lab4d3.txt is the input file. All the rest are .java files that have been renamed .txt. Of course Output_Version2.txt is the output I got when I ran lab4d on command line using  java lab4d < lab4d3.txt.

So once again my problem now is that the first line should not show up in the output but it is. If you can tell me why this is happening, the question can be closed.

Thanks,

Ohjava

Version2.zip
0
 

Author Comment

by:ohjava
ID: 22802083
Hello,
Please find attached the fianl version. It includes the desired output. The inout file here is Input4d3.txt and the output file is Output_version3.txt. Please run at the command line using
java lab4d < lab4d3.txt
Final.zip
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question