masijade 1,351 Industrious Poster Team Colleague Featured Poster

setting the preferred size on the components before calling pack would also resolve the issue without having to remove the call to pack (which you shouldn't do).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

gmtime() instead of localtime()

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Who gave a negative reputation for this response?

Anyone should be thankfule to read it, as it explains a lot about the problem.

My God, some people are just not sensible.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Stop posting your homework/quiz questions.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

because you do

Node top, np, last;

Then, the very next time last is seen, it is in the else block and you are attempting to dereference it.

} else {
  last.next = np;
  last = np;
  bigInt = in.nextInt();
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

http://java.sun.com/ It is of course, part of the standard JDK. Read the API docs for java.awt.print and javax.print and look for the tutorials.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So who told you that? That idea sounds just fine. There is an entire printing package in Java, and I don't know that the printing part of the program would be the deciding factor anyway. Especially since you could simply create a file (text, PDF, etc), or a webpage or something, for output and let the user print it using some other program, if you have trouble with that part of it in Java.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That's what I thought. You're not looking for a title, you just simply cannot come up with your idea. Coming up with a project is one of the points of leaving the choice of project up to the student. So they can show some creativity. Both in the selection of a project and in the coding of it (which should be better than the assignments were, since this is something that the student wanted to do himself, and so should be done with some passion). So, come up with a few ideas, and then post those ideas here, and we can tell you which ones, if any, are either too ambitious, or too simple, or simply too common.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

>System.out.printf(inventory[counter].toString());

I do not think there is any function like printf in Java. It should be either print or println.

As of 1.5, yes there is, but it is not used in this manner. You need to pass it an optional locale object, a format pattern string, and an array of objects to match the arguments in the pattern string.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, what's the content going to be? Don't worry about the title until you have an idea of the content.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And like I said, LookAndFeel. It takes about two minutes to find a tutorial on it, if you look.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

LookAndFeel

Google that term.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm sorry, but, why did you ressurrect this two year old thread?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You are getting a download box, because the browser (I assume your on Windoof) does not know what to do with files that have an extension of ".bat", so it is asking you what it should do with it. You need to add a mime type for ".bat".

This entire action, is, however, wrong on so many levels (technical, practical, and security levels) that I cannot even begin to list them.

Edit: Or a mime type exists, but its action is save/download, in which case you simply need to cahgne the mime type. But see my above comment.

And, on a side note, why did you open a new thread for this, rather than simply replying to my post in your other thread?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

?

No idea what you are talking about.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

toCharArray() ?

Read the API for String.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

if you wanna compare the value i think you cant do (a - b > 0) you have to do eiher:

int dif = a - b;
if (dif > 0);

or

if ((a - b) > 0)

Wrong.

I'm sorry, but, take two minutes to perform a test and you can avoid making false assumptions like this.

Edit: I mean, both of your examples, of course, work, but so does the original, making your "workarounds" unnecessary (although I will often use the second myself, to make maintenance of the code, for some of the novice programmers we have here, clearer).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you have put the coins into the machine (which is how I read the post since you said "insert 2 po....") then you are only worried about the calculation of the change. So start with the biggest and work your way down and you will come up with 2 pound and 5 pence coins as change.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I would have vary hard time explaining you, since I have no idea who/what you are, or what your purpose is.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Start taking out from the largest to the smallest coin.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well at least give it a try. Post the code and all error/compile messages as well as what it does (not) do that you expected, once you have written something.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

because 2 != 222 or 22. If you really need to match each digit, then you need to parse each digit of the number as an Integer, rather than the entire String, of course. Try to work something in, in between the readLine and the parseInt and then, if it still doesn't work, post that modified code and clearly explain the problem, with all error/compiler messages (if any).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

We are not going o do your homework for you. If you provide what you already have, we help to point you in the right direction though. And, if you bother to post (or write) your code, don't forget to use code tags.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So write it now, please.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, if it starts with "/*" then either that is the problem, or that code is not the problem, as it is commented out.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google "Java File Upload" and "POI" and read the JDBC tutorials.

And, don't do this from a JSP, use a servlet to kick off the request, and supporting classes to do the actual work.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Masijade,

I finished the file comparison in MS Access.But I am trying to do the same file comparison using Shell script...Thats why posted you a thread..

I didn't understand this line in your script :
grep -v $line /tmp/b1.txt >/tmp/b2.txt 2>/dev/null

Can you please explain?

Thanks in advance
Regards
dave.....

grep -v means to match everything except the next text (you should probably place $line in quotes) from the the first file listed (b1.txt) and output it to the second file listed ( > b2.txt) and ignore any error messages (2>/dev/null).

The next line then moves b2.txt to b1.txt so you can repeat the procedure with the next line. Once you have gone through all lines, b2.txt contains all lines from b that were not in a.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

To tell you the truth, that may seem efficient, however, once returned, the rest of th program must then "parse" that String to extract the info (it won't necessarilly only be used for output), whereas that object will allow the rest of the program to directly access the data without having to parse it first.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay, I will try to say this nicely.

Given that the data to be read is 1001,11001, etc and given the text The binary number will be passed in as an array of Booleans (a true represents a 1 and a false represents a 0) it seems faairly obvious that you need to create the binary array yourself. It's a stupid requirement, yes, but that's the way the world is. I've seen requirements much worse in real projects.

Now, maybe it's just me, but that all seems to be glaringly obvious, so your first post said to me (reading between the lines), "write (at least this part of) the program for me". Which was the reason for my first post. I apologize if that was not the case, but that is the way I interpreted the first post (and we get that here so often it has become the norm, rather than the exception).

But, in any case, read in the String, create a boolean array of the same length as the String, then loop over the String setting each element in the array according to the requirements provided in the assignment text. (Really, you only need to worry about the ones, as a boolean array is initiated with all elements false, which is how 0 is to be represented.)

Edit: And a boolean is, yes, a boolean. But, what is a boolean? It is a switch, an "either/or", in other words, which is also exactly …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Whatever. Continue on in your world of percieved slights. I'm not the one here asking for help.

You know what they say about biting the hand that feeds you.

And, you can prefer anything you wish, not that you can make it come true.

Edit: But, it's fairly obvious that you read in the number anyway you want to, and create the "binary array" from the read string (I assume from that snippet that you read the "number" already in binary format) and pass that array to the method that is to do the conversion. It is kind of hard for your program to receive the input as an array already already (unless it is to read it over a socket using an ObjectIputStream or something, which is beyond the current class objectives, I would assume) so it should also be fairly obvious that you need to create the argument you pass to the array from whatever you read in, reagardless of how you read it in, so, I don't see what has been giving you a problem.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Almost word for word.... thats my issue, I'm confused by the wording of the assignment...

As to it looking like I wanted you to do it for me...

Next time, don't make poor assumptions and you would avoid looking like an idiot?
Don't take your anger out on me because you didn't read the question and are suddenly surprised when someone points that out.

No where in that first post did you give any indication of having done any work. Made a lot of statements about "I thought" "I tried" but didn't show any of that effort, and it's easy to claim. So it was still nothing but a "do my work for me" post. And the only one looking like an idiot is you doing your "I didn't say that" backpedaling.

Everyone keeps mentioning a boolean array, where the heck is it? Or, am I already done and the bit about boolean arrays in the problem wasn't necessary to solving it?

You mentioned the boolean array, here the quote from your first post The binary number will be passed in as an array of Booleans (a true represents a 1 and a false represents a 0.).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes I do know that a boolean array is an array of booleans, but when you said binary array, I wasn't sure if you meant the array of integers, as I've never actually heard of a "binary" array. In the op the text I copy and pasted seems to refer to an array of booleans, while the test data hes provided (http://www.shenet.org/high/hsacaddept/technology/chanley/assigns/2007/Test%20Plan%20for%20Method%20Pract.pdf) here, (problem n, seems to show the input as an int.

He refered to it as a "binary aray" because that is essentially what a boolean array is. Binary is 1 or 0, boolean is true or false. So, in the sense of this homework assignment, that boolean array is a binary array. Each boolean array element is one bit in the binary sequence.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See that's just a rude comment. I of course actually read the policies, and am well aware that it would not make sense to just give me the answer. Maybe you should take time to consider that not all people on the site are as ignorant of the rules as some. Notice the part where I'm taking AP Comp Sci? Anyone in even the basic Java course could make a good stab at this problem. What I wanted was help understanding what he wanted me to do and what he was talking about in the second sentence.

Here's code to do it using an array of integers.

Tester
case 3:
            System.out.println("Please Input a binary number");
            String ys;     
            ys=sc.next();      
            int [] binary = new int [ys.length()];
            for (int i = 0; i < binary.length; i++) {
              binary[i] = (int)ys.charAt(i)-(int)'0';
            }
            System.out.println("The number in base 10 is " + (mp.binToInt(binary)));
            break;



Method
  //pre: Given a binary number
//post Returns the decimal equivelent of the number as an integer
  public Integer binToInt(int[] binary) {
    int decimal = 0;
    for (int i = binary.length - 1; i > -1; i--) {
      decimal += Math.pow(2, (binary.length - i - 1)) * binary[i];
    }
    return decimal;
  }

And no this is not just a rude comment. You posted your homework assignment, almost word for word it looks like, without giving any indication that you had done anything at all. What is anyone suppossed to infer from that other than "Do my homework for me"? Next time, …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So, wht do you have so far? We are not going to do your homework for you, that is not only morally wrong, it is against the Daniweb terms and policies, which you agreed to when creating an account here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Include the link to it, just like in every other HTML page?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Although all you really need to do is look at his moniker to find out what he wants here.

"chetah" when sounded out is the current "slang" sound for cheater. The "street" sound for "er" is, now, almost always "ah".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You don't compare Strings with either == or != use

while(!"stop".equals(fName)) {

And, before you ask, putting "stop" instead of fName first, avoids a possible NullPointerException if fName happens to be null. That does not mean you won't have problems inside the while if it is null, so you should probably do

while ((fName != null) && (!"stop".equals(fName)) {
masijade 1,351 Industrious Poster Team Colleague Featured Poster

a's got 100
b's got 9
you need the 91 uniques - I'll put 'em in c.txt

while read line
do
   grep $line b.txt >/dev/null 2>&1               
   if [ $? -ne 0 ]
   then
       echo $line >>c.txt
   fi
done <a.txt

Sorry - just needed to drop a post somewhere - it's been a while :)

, Mike

Its actually easier, if with a few more file operations.

cp b.txt /tmp/b1.txt
while read line
do
   grep -v $line /tmp/b1.txt >/tmp/b2.txt 2>/dev/null
   mv -f b2.txt b1.txt
done <a.txt
mv b1.txt c.txt
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes he does, and I believe that is his problem. Although it would have been nice to know which line "34" was, without having to count.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Don't put conditions in for loops...

Nothing wrong with it. However, you must be aware that if the overall condition returns false, the loop ends. If you wish to skip a single iteration of the loop and continue with the next, then use only the standard condition (i.e. i < whatever) and add an if statement inside the loop for the other conditions. If that if statement returns true, then use the continue keyword. E.G.

for (int i = 0; i < someNumber; i++) {
  // maybe perform some partial loop actions
  if (someCondition) {
    continue;
  }
  // perform loop action
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Hi, what to say "just a coincidence":) , I represent my company and we offer a solution for SVN and Tomcat.

In this sort of case, I don't really mind the advertising (although it should be reported), but, the least you can do is to identify yourself as a member of the company (or the owner if you are either of those) when you make the recommendation. To do anything less is misrepresentation.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Also am trying this in microsoft Access.

What do you mean by this? This forum is for Linux/Unix Shell Scripting, not Windows Batching (unless things have changed).

As far as doing the comparisons, an easy, but not necessarily performant way is a simple grep command.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The tomcat documentation spells this out rather clearly.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Cool. What do you have so far, and what problem are you having with it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

JNI, your only real hope. But, somehow, I get the feeling that his entire project is beyond you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have asked to have the thread moved.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, the contentPane of the the JFrams already has a layout. It simply needs to be used correctly. If you use add without any anchor parameter then according to the documentation
As a convenience, BorderLayout interprets the absence of a string specification the same as the constant CENTER

So, simply calling add(Component) twice, is the same as calling add(Component, CENTER) twice. She should be calling add(Component, CENTER) and add(Component, SOUTH), for example.

Of course, changing the layout (as your post showed) is always an option, but is not, strictly speaking, needed.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, don't mix them. Eliminate the scriptlets altogether. You should be doing this stuff in Beans, and the like.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

It has nothing to do with the JDBC code (excpet for where it opens the file), and everything to do with how you are retreiving the file. Seemingly, according to the error messages, you are not uploading a file into the db, but simply saving a local file into the db.

You should not be attempting to open a file. The file upload request contains the file, you should be using the inputstream from the request, n ot attempting to open a file.