verruckt24 438 Posting Shark

@notuserfriendly : The logic for postfix evaluation is pretty straightforward. Move over the postfix string/expression and push any operands (numbers) into the stack, whenever you find an operator pop the topmost two operands from the stack and evalulate them, then put the result back onto the stack, continue moving over the string in the same manner until you have reached the end, when you reach the end of the expression, pop the lone value from the stack. This is your result.

verruckt24 438 Posting Shark

You cannot call a class from within another class, but what you can do is call a public method of one class from another class. Here's an exmaple:

public class Demo{
    public void callMe(){
         // callMe code
    }
}

Now we will call the callMe method in another class. For that we do need an instance of the class Demo (which contains the callMe method) in the second class. Here's what we do:

public class Caller{
    public static void main(String [] args){
        Demo d = new Demo(); // create an instance of Demo called [I]d[/I].
        d.callMe(); // use d to call callMe
    }
}
verruckt24 438 Posting Shark
Voter[] v1List = new Voter[];
for (int i = 0; i < 3500; i++)
{
v1List[i] = new Voter();
}

This will throw a compiler error, "array dimension missing", which is caused by

Voter[] v1List = new Voter[];

The JVM would know what type of memory to allocate, but not how many such types there wouuld be, so the compiler won't allow this. Change this to:

Voter[] v1List = new Voter[3500]; // or however objects you need to create
verruckt24 438 Posting Shark

u need to implement the stack
then do precedence with switch cases
ill give more info once i get home, but at least show some code that you wrote not the code from your resource material form CD

Why is that, that you believe he copied the code ?

@OP : Read my prvious post I've underlined the problem there.

verruckt24 438 Posting Shark

Since you have code from two different sets I guess you will have to use two different charsets here and check the character code while reading from the file, if the character code is in the range 0800-00FF i.e. Latin-1 use the charset ISO-8859-1 if it is from the set 0100-017F i.e. Latin Extended - A use the aprropriate charset.

PS : I do not know the charset to be used for Latin Extended - A, like you use ISO-8859-1 for Latin-1

verruckt24 438 Posting Shark

If you observe more closely all the characters that have managed to get convered are from the set Latin-1 (0080-00FF) such as Á - \u00c1, ú - \u00fa, á - \u00e1, í - \u00ed. The only character that is not from the Latin-1 set but still gets converted is š - \u0161 which belongs to the Latin Extended - A set. But thats because the encoding windows 1252 consists of characters from ISO 8859-1 as well as ISO-8859-15 where the | is replaced by š for 0xA6 from ISO-8859-1

verruckt24 438 Posting Shark

Are you sure you should be posting this here and not on the C# forum ?

verruckt24 438 Posting Shark

Hmmm...., I agree to disagree with you for the fact that you are wrong !!!

verruckt24 438 Posting Shark

From what I get from the first glance at your program is that, your for loops are working correctly and you are creating 10,000 Voter objects but in the first for loop you are assigning all the 3500 objects to the same reference v1 in the next you are assigning all the 3500 objects to v2 and same for the third when instead you need to have an array of those many objects.

verruckt24 438 Posting Shark

Yes, I did look at his code, and I knew he was using double, and I knew the problem was with the display, not the calc, and I admitted it was a guess that 11! was > max int

If you already knew he was using double, why then comment on the int at all, where does it come in between ? Which made me think you hadn't looked at his code at all. Cause you were hinting at something that was not even remotely related with the cause of the problem.

I just gave him the quickest way to get the output he was looking for - which seems to be what he wanted, judging by his reply.

Giving ready made solutions or trial and error tricks is not whats expected here, when suggesting a solution, underline the problem to the OP so that he can avoid it in future and then present your solution with the reasons for them. Doesn't this seem to be a much better approach then saying something like "Try this out for a solution and don't ask me why the previous one failed in the first place cause I've got no clue at all"

verruckt24 438 Posting Shark
scan.nextLine();
String str = scan.nextLine();

This is what causes the problem. You are already moving your scanner past the line read. Remove the first scanner.nextLine();
Read the Scanner docs here for more details.

verruckt24 438 Posting Shark

I haven't seen many people complaining on that, enough even to be called a minority, just the one. Also this to me doesn't appear to be an issue that the community should bother itself too much with, more so when people always have the wonderful solution put forth by AncientDragon. It's just a copy-paste far.

verruckt24 438 Posting Shark

I suspect that 11 factorial is greater than the maximum value of a Java int (about 2,000,000,000), so you'll have to use a different data type (eg long) to go bigger.

You haven't even taken care to look at what he is using for the result of the factorial before commenting on the int capacity. He was using a double. Also try checking it yourself, even with b declared as an int he could easily go upto 16's factorial before causing any problem. And you haven't cared to understand the problem and explain the same to him. Refrain yourself from posting wrong information.

@OP: The problem is caused because you are, (were, infact) using double, not that it gives a wrong answer, it gives it in a format that would have caused you to get confused. I ran the program and here's what I observed.

The factorial of 11 when you declare b as double given by the program is : 3.99168E7, when you declare b as int is 39916800, now let me tell you, if you don't already know, that 3.99168E7 means that 3.99168 * 10^7 now you don't need a super computer to tell that the answer for that is 39916800. The same thing happens with 12, for b as double it gives 4.790016E8 as an answer and b as int gives 479001600. Again they both are the same.

So, in essence, double does not give you the wrong answer but the correct answer in …

verruckt24 438 Posting Shark

All the errors point to just one thing that the symbol/variable input is not declared.

input = Integer.parseInt(br.readLine());

In the above code of yours, have initialized input but havne't declared it anywhere, declare the variable before using it.

Note: Also paste your code in code blocks in future so that the trouble of saving/opening it can be avoided on our part, also you can copy paste the error in the post itself.

verruckt24 438 Posting Shark

The code you have posted earlier does not contain this anywhere

System.out.println("Element at index 1: " + scores[1]);

So post the new code again. Also I am obeserving that even after so many posts you aren't taking much from them. Read the posts carefully, it isn't much difficult a task and you have been already given enough pointers but you don't seem to learning much from them. It would help to learn one thing that we aren't going to spoon feed anyone here, giving him the code in parts one by one explaining everything to him one at a time, we need to see some effort better than this from you.

@BestJewSinceJC : Yes you have a point there, that when you declare a variable false a while condition checking that variable will never enter the loop, but the problem he mentions - "cannot-find-symbol" will not be caused by that anyway. Why it does cause can only be told when he posts his new code.

olgratefuldead commented: Very helpful +1
verruckt24 438 Posting Shark

Read post #6 by me again, it is a typical example of recursion to calculate the factorial upto a number n. The method you have shown is not recursion, since recursion is a call to the same function within that function itself. So if you see the recursive method shown in post #6, the factorial method gives a recursive call to itself with one less than the number. Meaning a call to factorial(n) would result in a recursive call to factorial(n-1) which in turn would result in a call to factorial((n-1)-1) and so on till the termination condition of the recursion occurs which is when n finally becomes 0.

In your case, whenever you give a call to treeInsert(node) you need to check if node.left is null, if yes, create a new node, insert the data into it and assign this node to node.left, if node.left is not empty, do the same for node.right, if that too is found to be not empty, give a call, and here is where recursion comes in, to treeInsert(node.left) and the story continues in node.left.

verruckt24 438 Posting Shark

The DBMS will take care of that, you do not have to worry for that.

verruckt24 438 Posting Shark

If that solves the query mark the thread as solved so that people are aware of the fact and do not post anymore on this thread. Else we do have a lot of old threads revived unnecessarily.

verruckt24 438 Posting Shark

well if the query has been solved mark the thread so.

verruckt24 438 Posting Shark

You could write a MySQL query for this like:

SELECT Name FROM tablename where type = '<type>' and price <= '<price>'

Once you have the result for this, you could show it using PHP.

verruckt24 438 Posting Shark

620

verruckt24 438 Posting Shark

i have alrady gone though the code on the specified links

You haven't gone through anything, if you would have gone through, your questions would have changed, but you keep asking the same, lame questions again and again.

i didnt find any link where we can use apache poi and itext together so asked... can u able to provide me link where apache poi and itext has been used together?

You are still asking for spoon feeding like a baby.

i guess this forum is there to explain the things

Have you gone through the forum rules, if not go through them, if yes, still go through them again and try to understand them this time. We aren't in anyway obligated to help you.

and if somebody has alrady implemeneted the things is really helpful

Translation : I would be happy biting on ready made food than to cook it myself.

i guess u guys wont implemet anything and just post the link

Yes, rare enough but you are right this time.

Giving you one last hint, if you have the smarts to take it.
Go read how to read content of an excel file with Apache POI. Once you know how to obtain the content, go read how to transfer it to a pdf file using the iText library. That's all that you are going to get from me.

verruckt24 438 Posting Shark

You say you don't need spoon feeding, but what else are you asking for then, when you say "Please explian the useage of apache and itext together???". You have been given the links, you can go read the contents there, which I am sure would be more better in explaining the usage than anyone over here. What do you think we are going to do when we would be explaining you the stuff, we would read the contents on the site as well, why then do you need our interpretation for that.
If you are not aware of the customs here, let me tell you that we would be giving you only pointers in the right direction, which you have already been given, we aren't your tutors to do the explaining part for you as well.

verruckt24 438 Posting Shark
int [] scores = new int [4];

You declare your scores array to be of size 4. And you put all the things from index 1 to index length-1 of strArray into the scores array. So, in essence, your strArray should contain no more than 4+2 i.e 6 elements. And according to the current format we assumed that should be the case, that is the reason I told you that I assume the format is the same for all. Now if some of your records are going to contain more than 6 elements, or more appropriately, more than 4 scores you should declare scores array in this way:

int [] scores = new int [strArray.length-2];

This will ensure that you never run out of bounds with the scores array.

verruckt24 438 Posting Shark

Okay, then will you be kind enough to remind us about that ?

verruckt24 438 Posting Shark

You can print out the output in CSV (comma-separated-values) format and then open this file in a spreadsheet application like Excel. If this is not what you want, detail out your problem.

verruckt24 438 Posting Shark

For a custom search, what you can do is, have multiple queries written each for a different search that can be done on your database and select the appropiate one to fire, dynamically, based on the search parameters entered by your user.

verruckt24 438 Posting Shark

you could always copy/paste into your own favorite editor, such as Notepad++ which will do what you are looking for.

@OP: Didn't you figure this out ?

verruckt24 438 Posting Shark

If you read my previous post carefully, I have shown the iteration being done after the line has been read from the file and after it has been splitted to get a string array.

verruckt24 438 Posting Shark

@naveen : Good point there about the keywords, but I guess he has framed his question wrong.

@OP : Would you be able to define a custom search in more detail or reframe your question, cause "district = all, typ = all and price = all" is not a search at all.

verruckt24 438 Posting Shark

Thats why I said make it optional. Or mabey even on a toggle.

If thats the case you can toggle plain text on it and check out, that feature is already there.

verruckt24 438 Posting Shark

Use recursion to insert nodes. Recursion is basically a function calling itself. A simple example of recursion is as follows:

int factorial(int n) {
   if (n == 0)
      return 1;
   else
      return (n * factorial(n-1));
}
verruckt24 438 Posting Shark

Build and exit key: I built an exit key using the number 0, but somehow I think it is entering into the formatted equations and changing the response I'm expecting. I could be wrong. I'm very very new at this.

Thats the reason I suggested you a menu, at every stage of input taking, you could have a different exit key, which does not fall into the range of valid inputs for that stage.

verruckt24 438 Posting Shark

You check the mysql binary log, so as to know what the server was doing at the time of the crash.

verruckt24 438 Posting Shark

Latitudes and Longitudes would help you in almost zeroing in on any place. When detailed right down to seconds you can pin point any place on the globe. But do you always want such pin pointed accuracy ? Or sometimes you would do with just identifying the "region" of the place. In that case, Timezone, Continent, Hemisphere would be other such attributes that would be able to "roughly" let you know of the place's location.

verruckt24 438 Posting Shark

So then when the line runs longer than the maximum width allowed for the post screen, how do you plan to show that ?

If you use horizontal scroll bars for it, then lines can become too too long. This again causes problem to read, as one has to keep scrolling back and forth. Also after reading a long line, it's confusing to figure out the line exactly below the current line.

For better reading abilities it's always good to keep the line upto say 80 characters. It's like in the newspapers even though they have lot's of width they prefer to break a long article into multiple vertical columns than to allow the lines to stretch to length. ;)

nav33n commented: Exactly! +10
verruckt24 438 Posting Shark

hi stultuske
can u help me for making online examination interface in java

Lame, Lame, Lame !!! I have no other words for you. You don't check the dates of the last post, you don't care to check for the forum rules, and on top of that you ask a lame question without showing any effort.

verruckt24 438 Posting Shark

Well I guess someone is going to close this thread pretty soon, but just before that happens let me squeeze in my views from what I have observed in this thread. (I had read it earlier too)

Okay, IMtheBESTatJAVA, I am wanting to believe you that you did not disguise your homework and that assignment matches your becuse you got it from the net whilst you were searching for some problems, but there are somethings that make me not do so. Here are they in the chronological order:

1. When someone wants to start off a discussion on something, like in your case the assignment/problem, he almost always starts off with presenting his views and then asking others for theirs. In a way like "I think blah blah blah about this, whats your opinoin guys". These were found to be missing from your initial post.

2. You mentioned in your second post

You don't even have to post your answers guys

This again was found missing from your initial post, if you were never looking for answers in the first place and just wanted people to trigger their thought process, why not make it evident from the onset. This makes me think that initially you did want the answers, but now after the covers have been blown you want to show off how less you care for them.

3. You mention in your second post :

If this was any attempt to disguise my homework and …

verruckt24 438 Posting Shark

To explain, lets take one of the records you have mentioned. Say "Obe 20 12 15 20 -1", this is the first line in your file. When you do:

first = inputFile.readLine ( );

first contains the entire line "Obe 20 12 15 20 -1"

After that when you do:

String [] strArray = first.split(" ");

The array contains:
strArray[0] = "Obe"
strArray[1] = "20"
strArray[2] = "12"
strArray[3] = "15"
strArray[4] = "20"
strArray[5] = "-1"

Now when you already know this format, you can start converting the strings from index 1 to 4 of the array doing:

int [] scores = new int [4];
int j=0;
for (int i=1;i<(strArray.length-1);i++){
    // you begin i from 1 since at index 0 you have the name
    // you end the loop when i equals one less than array length since the last integer is always going to be -1, you don't need to bother  parsing this.
    scores[j++] = Integer.parseInt(strArray[i]);
}

Now you have all the scores for "Obe" in the scores array, you can proceed to doing the sum/average math on it like you would have done with regular integers.

verruckt24 438 Posting Shark
// We define a string
String str = "olgratefuldead learns java";
// We use the split method of the String class to split the string on spaces.
String [] strArray = str.split(" ");
for(int i=0;i<strArray.length;i++){
    System.out.println(strArray[i]);
}

The output for the above code will be :
olgratefuldead
learns
java

The code above creates an array of Strings. An array is a collection of similar types. If you know String, it's quite simple to know arrays of Strings, it's just like multiple String objects put together one after another. You can learn more about arrays in Java here

verruckt24 438 Posting Shark

> I must also format the pay as currency
Do you mean having decimal points ? If yes then you could define your pay variable as float/double according to your requirement.

> Build an exit key
What you could do is have a menu printed at the start of every calculating stage mentioning the user about the options, say 1. to enter hours worked, 2. exit. Something of this sort. Then process accordingly.

verruckt24 438 Posting Shark

I assume here the numbers are the score over which you need to make an average, "-1" is the termination indicating character and the first string in a line is the name of the person.
Well, what you can do here is read all the lines entirely from the file one by one, into an array of Strings. And then split each string into an array of other strings that the line contains. In the second case the strings would be the name, scores and "-1". (I am assuming here that the format of the record remains same for any record) After you have done that, you can iterate through the second array collecting scores (currently strings) and converting them to 'int'. Once you have done that I suppose you can as easily perform the sum/average math over them.

verruckt24 438 Posting Shark

@weblover : The thing is not that only when all the checkboxes are selected the code would work. Only when the last checkbox that you add is selected, that the code would work.
Reason : Something similar to what you were doing with your placement of labels earlier. You use the same room (JCheckBox) object to store all the instances of the generated checkboxes, so that 'room' contains the reference to the last such object added. Now when you check room.isSelected() it checks whether the last room is selected and would obviously won't work if it isn't. Now when you select all rooms/check boxes naturally the last one is selected and your code works. But when you select anything other than it, your code won't work.

You need to keep a list of all the generated checkbox instances and check which all are selected, and do the calculation of the total depending on it.

Edit : Just a word of wisdom, using words such as urgent and phrases such as "as soon as possible" would only make your helpers ignore you. Nobody here is obligated to help anyone, it is a matter of choice and nobody likes to be pushed to do charity.

verruckt24 438 Posting Shark

@masijade : No don't feel so, not at all, Actually since you said he was wrong altogether, I mentioned the thing.

verruckt24 438 Posting Shark

You can assign only access privilege to the standard set of records (I assume they are in a separate table) to the group. So that they can certainly generate other records using values from the standard records but not edit/delete them in anyway.

verruckt24 438 Posting Shark

Like it.

Dune bashing ?

verruckt24 438 Posting Shark

Whats that ?

Did you see the oscars ?

verruckt24 438 Posting Shark

tram, volcano, silicon, ultra, microscope.

terminus

verruckt24 438 Posting Shark

-1151

verruckt24 438 Posting Shark

618