stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You can start here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Sounds like an assignment question, can you tell us the answer from whatever research (reading books or the resources on the web) you did ? We will add to it or correct you even, if we see you have put in the effort to really find out.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
INFO main org.apache.catalina.core.StandardEngine - Starting Servlet Engine: Apache Tomcat/5.5.26

One more thing I forgot to mention last time out. If this is a Linux Server I have a **feeling** that your ISP was using the Tomcat which was acquired in that O.S's software repository, These versions are by default configured to use "gcj"(which is I **suppose** compliant with only JDK 1.4.2 specs) and not the Sun JDK/JRE, So you also might want to ensure that they have an appropriate version of the JRE installed.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

This is more of a core java question, So it should have been posted in the Java forum.
Anyways take a look at the javadocs of the String and StringBuffer class you might find what you are looking for there, most probably it is the substring (1,2) menthod..

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First of all you will need an API (provided by one of various currency exchange websites) which will feed you the data if you want live /real time exchange rates.
I normally use www.xe.com to check currency rates, they also have their own data feed product where they will post you their data in XML,CSV or just in a plain old HTML table, however you need to pay for it and I do not **think** that any of these sites will let you use this service for free (Of course I could be wrong).

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Tomcat by default doesn't have support for JSF (amd definitely Tomcat 5.5 doesn't),
Are you sure the new place has the JSF libraries because the following suggests the JSF libraries are mssing.

java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener

Also have never seen as yet anyone use JSF with a Tomcat version prior to 6.0.

peter_budo commented: Good tip +14
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well to calculate days I would prefer a more simpler method like this :-

// Current day would store the index of the day in the Array
// 0 points to Sunday.

int currentDay = 0 
String days = {"Sun", "Mon", "Tue", "Wed", "Thr",  "Fri", "Sat" };

// Now if you want the day 10 days 
// after current day just do

String afterNextTenDays = days[(currentDay + 10) % 7];

String nextDay =  days[(currentDay + 1) % 7];

Similarly you can go on for all your combinations.
Also it is not exactly foolproof, you will need to take into account the special case when the currentDay is Sunday (and so set to 0) and the User asks for the previous day. In that case the formula in the square bracket would become [(7-(currentDay - noOfDays)%7)%7], this formula would be needed whenever you want to calculate a previous day. Looks kind off complicated but I guess there should be an easier way.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My suggestion for your Line equation class is, do not store it directly as :-
y = m(x-x1) + y1

Instead store it in a reduced format as
y = mx + c
or
mx - y = - c --> Preferred as you will see in the last point.

And as you can see c = (y1-mx1), and ensure that you reduce all common factors, that is if you have an equation as 2x+2y = 2, reduce it to x + y = 1 , so that whenever you have to use the equations either to solve them simultaneously or to just to compare them, you can do so directly without any extra processing.

Also I think you might be interested in how to solve linear equations simultaneously using the determinant method as that is an easier option to program in your code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No problemo.
Best of Luck in converting that to code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well I see that you have specified a line segment to have two end points.
Now to check if lines are collinear you will have to get their equations and solve them simultaneously.
Now the equation of a line with slope "m" and with point (x1,y1) on it is given by :-
y = m(x-x1) + y1
You will need to define data members in your LineSegment class to store this information.
Once you have got the equations for all your line segments, to figure out if they are collinear or just intersecting you will have to solve the equation of any two of the line simultaneously.
For example consider we have three lines with the equations:-

Line 1: 3x + 4y = 3
Line 2: 2x - 2y = 7
Line 3: 9x -y = 0

You will need to solve any two of the equations simultaneously, to find the intersection points of the lines. That is if you solve the equations of Line 2 and Line 3 simultaneously you will get the intersection point of Line 2 and Line 3.
Next if you solve the equation of Line 1 and Line 3 simultaneously you will get the intersection point of Line 1 and Line 3.

If the intersection points in both the cases (Line 2 & 3 and Line 1 & 3) are both the same, then it means that the three lines are collinear and …

oldSoftDev commented: Awesome explanation +2
verruckt24 commented: That's a good bit of work in there. I thought of anwering this, but then couldn't find the time recollecting facts about lines. Keep it up. +2
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Honestly there isn't enough information to suggest anything other than wild guesses.
Can you tell us the structure of your Point class, Line class etc, so that would help us see the problem from your perspective.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now I am going to make some assumptions here on your merge method, My main assumption is if your method is called as arr2.merge( arr1 , arr); then you want the contents of arr1 and arr merged and in sorted order inside arr2.

Now if thats the case, why don't you parse the contents of "arr1" and "arr" separately and insert them into arr3 by calling arr3's insert() method, and as long as you are sure your insert method works fine, so will the merge method.

What I meant was something like this:-

public  void merge(OrdArray arr, OrdArray arr1)  {
  for(int i=0;i<arr.nElems<i++) {
    insert(arr.a[i]);
  }
 // Repeat similarly for the next object arr1
. .
. .
}

So as long as your insert() method works fine, your merge() method should not have issues.
Also a suggestion is refer to Sun Java Code Conventions, at least more important parts related to conventions for indenting and naming variables and methods.

Also you need to improve your skills in Object Oriented Programming, since in the program you are violating the principle of Encapsulation by making your member variables public. Your member variables should be private and in case you need to access them inside a different class implement the appropriate getter and setter methods that control access to these variables in an organized manner.

notuserfriendly commented: Very nice and simple implementation +3
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now assuming your File format is of the type :-

Albert Einstein 0
Stephen Hawking 3

You would need to add the following lines of code in your while loop before reading the grades like :-

.
.
firstName = inFile.next();
lastName = inFile.next();
num = inFile.nextInt();
.
.
.

Note:-
Haven't tested the code but I guess thats how it should work.
You should refer to the javadocs of the Scanner class for more details.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You could use the Logical (if I am correct) Operators ( AND (&&), OR (||) ) to achieve that. For example :-

while(status.equalsIgnoreCase("yes") || status.equalsIgnoreCase("yse")  || ..)

<EDIT>
Three posts in a minute on the same thread, thats the first time I have seen it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Maybe if you would have gone through the forums first you would have already come across this thread.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Most probably the issue is your tomcat running on port 8080, chances are you most probably have a firewall which is blocking that port from being accessed from outside. Also some networks tend to block outbound traffic on 8080 port as this is usually an intranet port.

You could either try turning off your firewall altogether (not recommended if it is on a public domain) or you could just open up port 8080 inside your firewall.

Although not related to your problem I see you ave placed the tomcat installation inside your "/root" and most probably are running your tomcat instance as "root" which is also definitely not recommended. (In fact if you might not be aware many people are of the suggestion that using Linux with Root is worse than using Windows).

I suggest you place it in some other folder for ex: /opt/ and use some non-privileged user account (for ex: "nobody") or maybe create some non-privileged user account without login privileges to run your tomcat. Also remeber in this scenario you will have to change the ownership of your files from root to the user which you will be using to run tomcat.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

<EDIT>
Never mind Sorry wrong thread

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
max = maxF(inputFahr);
        max2 = maxC(inputCel);

Err.. Doc, that happens cause, you are calculating the maximum temperature even before you have taken the input. By default in Java primitive numeric data types are initialized to "0", hence your Arrays -- inputFahr, inputCel contain only zeroes in them, when you se them in the above two statements and hence the maximum value returned to you is zero.

Also you are not really using the inputCel and inputFahr arrays declared in the main method, (Note -- the inputCel and inputFahr arrays declared in the tempC() and tempF() methods respectively are different.)
<EDIT>
If you ant to just fix your Code as opposed to programming it correctly, just declare the the two arrays "inputCel" and "inputFahr" as static class members and remove their corresponding declarations from the main and the tempC() and temF() methods.
Also move the two statements mentioned at the top of this post to below the while loop.
</EDIT>

Another point I would like to mention is you have currently used Java like any other Structured Programming Language my suggestion is the true power of Java lies in using it i the OOP way. You can check the sticky at the top for more links on improving your Java knowledge and Learn more about object oriented programming, here is also another useful link.

Another request would be to align your code consistently, it kind off looks awful to read the …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you are learning the concept of Binary Search Trees, Heap etc, it would be better option that you implement them by hand rather than using Collections.
That way you would understand the concept better and also improve your logical thinking ability and the ability of transferring logic to code.

However while designing real world applications I suppose the TreeSet, TreeMap or some other class of the java.util package will suite the job description better than you think right now.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Actually to convert from .doc to .pdf via Java I could not find a direct method, But I found a two step process,

  1. Access your Microsoft Format files using Apache POI, You can read more about it here.
  2. Next use iText to convert the data you have into a PDF.
verruckt24 commented: I missed the first step ;) +2
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Verruckt24, I guess the O.P. by now must have already figured out how to accomplish this task.
"bertt" is the culprit who revived this thread older than almost 6 months and whats worse he doesn't even provide a decent answer, let alone use code tags or anything else.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well the book I had was called Java 1.2. I don't remember what kind of java I had because I didn't know about versions but I believe I had Java Version 1.2

Exactly that explains the reason why like myself you too have opted for the BufferedReader, Scanner just never existed during our initial console programming days in Java.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I don't write console applications either but when I first begun I knew from my book only the BufferedReader.

That was most probably because when we learnt Java, java.util.Scanner did not exist.
I started learning Java from the 1.4.2 version of the JDK, and Scanner was introduced only in the 1.5 version and since console input is not so widely used by many of us, we opted to stick with good ol' BufferedReader.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Insert all the Strings that the user enters in to the args[] string array, since this array is being passed to each successive call of main, So you will have a list of all entered keywords in this array.

In order to check for repetitions just check if the entered word is present in the args[] array.

But instead of calling the main recursively I recommend you delegate this responsibility to some other method and let that method call itself recursively.

VernonDozier commented: Good point on the recursive calls. +11
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You will need to maintain a reference to the previous element also in the above code. Because as per your requirement you want to insert the new element before the element "temp" is holding a reference of when you are traversing the queue.

Now let us take analyse your code one line at a time :-

QueueNode temp = front;

This is fine, you are declaring the temporary reference to your start of Queue.

while(temp != null){
        if (temp.info > x)

Now your while condition states that you will should go through to the end of the queue. However there is a problem if your "if" condition, Consider you list contains the following elements :-

2 3 4 9 10

And you wish to insert the value "7",
Because of your "if" condition temp will enter the "if" block only when it is pointing to "9". And since this is a singly linked list you cannot traverse backwards. So you cannot insert "7" in the correct position in the list. For that you will need to also maintain a reference to node in your queue preceding the node to which "temp" is currently referring to.

temp.info = new queueNode(x);

Now over here this statement at least appears to be incorrect. Although I do not know your structure for class "queueNode", I am guessing "info" should be of type "int". Also you are overwriting directly the value present at the current location, You should …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well it depends she could be using a Priority Queue, in which members are organized in the ascending or descending order.

Also priority queue implementations may vary, some may do the selection of element to be removed at deletion time while others may do the sorting at insertion time so that elements in queue are always in a sorted order (based on priority which is what the O.P. wants here) for deletion.

Now to do the above, you will have to traverse your queue until you find an element that is greater than the element you wish to insert and then fit in your element there. Also let us see what you have tried.

<EDIT>
Also just my two cents, according to me a Linked List based implementation would be lot easier to implement than an Array based implementation.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

java.lang.ArrayIndexOutOfBoundsException: -1

Although I haven't gone through your entire code and neither followed up on the post, The above error strongly suggests that you are performing a Pop operation on an empty stack "stackArray2" (with Head as "evaltop")

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I asked for was some help, which I thought was the whole pupose of this site, but you have to be a jerk about it

The only Jerk I see is you who needs to be spoon fed with a solution to all his lifes problems.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Because I am working on an assignment for a Java class I am taking and am not sure what I am doing.

If you are not sure what you are doing, then you do not deserve to pass that class do you ???

So now I am not sure what have I done incorrect?

Let me guess you took the course which contained Java in it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You were the one treating me like I was an IDIOT

I guess you already proved yourself one, putting all that time and energy to writing this big post instead of concentrating on the clue I gave you.

I am not a CODER, so don't give me CRYPTIC answers I can't understand!

If you are not a coder then why do you even bother coding.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So can we CLUE me in as to where I need to put it?

Already gave you one look more closely at your "if" statements.

And considering your tone you can forget about a ready made answer from me. May be another poster might be kind enough to do some charity work for you.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I tried to put them below my prompts for hours worked and pay rate but that didn't work either.

Now I do not wish to be rude here but if you use common sense I guess any one can decipher that you cannot check whether a value is negative or positive BEFORE YOU HAVE EVEN READ IT from the console.

<EDIT>
Also it did not work because, closely monitor your "if" statements, all the "if" statements would be executed if and only if the user enters "stop" (for the employee name), now lets see if you can figure it out why ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The reason they are not working is because you are putting your "if" checks before you have even read them from the console.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So where is the problem ??

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I assume you want a Speech API for Java, So you can look here and here for that.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My suggestion would be you keep an Integer (say "counter") array with the exact size as the total number of names you read from the file.
And when you select any name at random from that String array (in which you have your names stored originally), just increment the integer value at the corresponding index in the counter array.
For Ex:-

Assume the names in the original names array are :-
names[0] -> Aaragon
names[1] -> Gandalf
names[2] -> Frodo
names[3] -> Sam
.
.
.

And lets say you selected on random "Sam", So in the counter array just increment whatever value is at index -> "3"
So you will know which name has been selected how many times at the corresponding index of the name in the "counter" array.

Note:-
There are better methods available especially using the Collections library in Java, but since you are just starting out I have recommended this one.
Also I haven't really read your code, I have just replied to the question above it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The above code requires that your system have an Echo-Server installed on your system.
Echo-Servers normally listen on port "7" and give back whatever you write on their socket.

If you are on any Microsoft OS chances are that no such server exists on your system. You can also test the presence of an echo server by typing "telnet localhost 7" on your command line and see if it connects. If it displays "Connection Refused", then thats a confirmation that there is no echo server on your system.

However I remember someone posting code for a custom Echo-Server on these forums, if you do a search then you should find it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now that I actually saw your code, you have actually reduced Java to the level of a Structured Programming Language, So in order to really design your applications better I suggest you go through this tutorial, for introducing you to the world of Object Oriented Programming.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I didnt see that someone else had replied

Almost everyone here tries to help and even verruckt would have if you would have given us the required details first and eventhough you would not like to hear it, verruckt is correct, although I do not mind the question on Java, you have not taught him to code properly. The first thing you should have taught him to do is get him to organize his code correctly, with proper indentations, line breaks etc. In case you too are unaware of any standard coding conventions, here is a link to Sun's Java coding conventions, you can either browse it online or download the PDF.

<EDIT>
Nice catch ~s.o.s~, that comment got by me

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
private JButton SubmitButton = addButton ("Submit Answer" ,1,9/8,1,1);

I think this is the problem, I do not see any addButton() function in your class Math4, which returns an object of type JButton.

I suggest both you and your student to go through this tutorial to get your concepts on creating GUI with swing right.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I am tutoring him, and ya sometimes I need help. And I will make sure he understnds the solution.

But how about you understanding us and pasting the exact compiler error and helping us help you help him ??? :P

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First one piece of advice : Use Consistent indentation, Some places you have indented your code, at other places you have just forgotten or put extra tabs for no reason.

Following is the lin for Java SE 6 docs:- http://java.sun.com/javase/6/docs/api/

Make it a point to look there if first your need some functionality from some of Java's inbuilt classes, for ex: "String" class in this case.

Next use the charAt(int) method of the String class if you want to access each of the characters individually, just like an Array.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Note: I know the code is not formatted well, with spaces and tabs. Sorry, it is no my code it is a student who I am helping.

Use an advanced IDE like Eclipse or Netbeans, they have features like autoformat using which you can automatically format any code, no matter how badly it is written.

And just as BestJewSinceJC said, paste the exact error (without editing it) the compiler is throwing up.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I would suggest compiling the program from your console and check whether you are still getting the same error.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Can you at least tell us what the compiler is spitting out at you ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I have tried using if (x[0][0] == x[0][1]...etc.), but this throws errors back at me

And what are those errors Java is normally pretty clear while specifying any errors in code.


And your thread title almost sounds like an ad in a matrimonial columns :P .

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Which world are you from, If you are not aware then "if" statements can be multiline too.
For ex :

if(.........) {
    a = true;
    b= false;
    .
    .
    .
}  else if (........) {
    a = false;
    b = true;
    .
    .
    .
    .
    .
} else {
    .
    .
    .
}

You can read more about it here

And please wrap your code in [code=java] and [/code] tags. It keeps your post organized and clean rather than the garbage you can see above. Its a bit irritating that this is your eighth post and you have not yet even glanced at the forum rules.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Actually when you consider serializing static variables, it doesn't make any sense, because the static variables are part of the "STATE OF THE CLASS" not the "STATE OF THE OBJECT".

However as far as your question goes, any variable not declared as "transient" (even static variables) would be serialized and their state stored.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well not so embarrassing, I remember another naive employee from my firm (you will not want to believe this one) actually SHREDDED the most recent copy of her project and she had conveniently forgotten to commit her code every night in our version control system.

So now back to the point, if you use a decompiler I do not know if your quality of code will remain the same, since there are chances that the java compiler might be performing optimisations on your code. My first option would be to try to recover the deleted data.
This would be possible if you are on Windows, there are quite few free and paid software available, Here are some free ones :-
http://www.aumha.org/a/recover.php
http://www3.telus.net/mikebike/RESTORATION.html
http://www.undelete-plus.com/files/

If you are lucky you will get your project back without decompiling.