verruckt24 438 Posting Shark

As mentioned in my previous post, I have for long lost touch with C++, but I assume from what I know, that none of the current collection of GNU compilers use the .h suffix. The new crop of compilers are bound to throw an error at you for that.

verruckt24 438 Posting Shark

From what comes to my mind immediately after seeing this, you are in effect copying only about half of the string since you begin by assigning i to 0 and j to the last character of the word, then you increment i while simultaneously decrementing j. i and j will meet somewhere in the middle so that rev only has about half of the characters of word. Now in this case strcmp will never return a 0.
This is IMO, a long time I haven't been doing a lot of C++, so tell me if I am wrong.

verruckt24 438 Posting Shark

You need to loop your code to print all the tokens. Something like:

while(st.hasMoreTokens()){
    // parse every token OR print it OR do whatever
}

Since currently there is no loop, it exits after printing just the first token.

Also note, the StringTokenizer class is a legacy class and maintained just for compatability reasons, it's use si discouraged. Use String.split() instead.

verruckt24 438 Posting Shark
for(int x=1;x<=(num);x++)

Since 1 is not a prime number don't begin your loop with it, rather initialize x to 2.

Definition of prime : An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself.

verruckt24 438 Posting Shark

You haven't initialized the input variable at the time that you are using it to get user input.

human = input.nextInt();

Initialize it to

input = new Scanner(System.in);

The thing is you need to declare variables, and then initialize them for use. If you do not initialize an object reference, then the value that it has is null , now when you use it to call a method then you get a NullPointerException since the object refers to null you cannot actually call a method on it.
If you check your code, in Player.java you do declare 'input' but do not initialize it before use.

verruckt24 438 Posting Shark

Okay if your query is solved, mark the thread as solved so that others are aware of it.

verruckt24 438 Posting Shark

My judgement here is that there was no infinite loop at all. When you are running a GUI based program you don't get to see any exceptions thrown by the JVM. Now, when your index counter was reaching 'size' then the JVM would have been throwing an exception which since your program being a GUI program you wouldn't have had an oppurtunity to see. This happens becuase the exception is thrown to the standard output stream which is typically the console. Since the program halted at that instruction the instruction

CompSciAPPane.showMessageDialog(All, APLabel, "Computer Science AP", JOptionPane.PLAIN_MESSAGE);

never got executed and hence you never got to see the JOption Pane which led you to believe that since there was no output, there must have been an infinite loop somewhere.

verruckt24 438 Posting Shark

@stephen84s : Yes but in this case, what happens if he inputs the number of adult tickets to be 110 ? You still ask him for the number of child tickets, which since he has already jumped the maximum count is wrong on our part. If he enters the no. of adult tickets to be greater than 100 he should be warned of the limitation there itself rather than proceeding.
Take a look at this post for a solution.

verruckt24 438 Posting Shark

You can use a do while loop to restrict no. of tickets entered from being negative or greater than 100.

Ex:

do{
System.out.println("How many tickets ?");
atickets = keyboard.nextInt();
// check for input being in the range (not < 0 and not > 100)
// if input is in range set flag to true
}while(flag==false);
verruckt24 438 Posting Shark

This is a problem of your JDK (JAVA_HOME) path not being set. Thats the reason the program doesn't get a java compiler. And if you read the ToolProvider docs, it says that the method getSystemJavaCompiler returns null if no compiler is provided.

In your Linux system, set the PATH variable to %JAVA_HOME% then export the path, by writing EXPORT PATH on the next line. For this to take effect you need to logout of your X-window system, so just do a ctrl-alt-backspace and login again, and then try to run the program.

verruckt24 438 Posting Shark

How are you creating the file ? If it is done with an absolute path then we need to see the code to tell you what might be going wrong. If it is created with a relative path in your program then the file certainly won't be created in the same place that it was created when the program was run from NB. It would be created in the directory from where you are running teh program now, i.e. your script.

Edit : Don't be shy to post your code, you have already been asked for it. It's only you who would be benefited since your query might get sorted out faster. Also if you are afraid we would steal your code, don't worry we won't. We just steal it when we have appraisals coming up and that too of the colleagues who trust us the most ;)

verruckt24 438 Posting Shark

Which methods ? Have you even cared to go through the iText library and the Apache POI ? They both are stable production quality libraries.
Do your homework before posting blindly.

stephen84s commented: Exactly the tone to use for such posts +6
verruckt24 438 Posting Shark

Whats wrong with you the answer has already been given here

verruckt24 438 Posting Shark

For everything that they can be used.
Typically for taking user input from console.

PS : Ignore this, masijade has given you the world !!!!

verruckt24 438 Posting Shark

no idea how the class file got there, i certainly didnt put it there. all i did was change the directory to Ass_5.

OSes are not habitual of moving files while the CPU is idle. ;)

for the program to find the .txt files they should be in the src directory shouldnt they?

No, they should be in the directory from where your classes are run. Typically in the classes directory.

Check from where your JCreator is running your classes.

verruckt24 438 Posting Shark

How does the src directory contain a .class file ? That tells us that everything is not in the right place.

On other thoughts, detail your problem if you want my solved threads count to go up, becuase I have a feeling I can solve this problem. It has all the characteristics of one, it is not concerning to Java, it only has limited players (a few files and directories) and on top of it , it looks trivial.

PS : Damn I should nail this one before anyone else does.

verruckt24 438 Posting Shark

Yes the (edited) previous post has the answer to your question.

stephen84s beat me to the previous post and then did not beat me while editing it. So kinda my previous post looks to be asking for the method code even after the correct answer has been given. :)

I hate you - stephen84s ;)

verruckt24 438 Posting Shark

Post the code for binaryGenerator method so that we would be able to run and chekc your code, what happens exactly.

And yes BTW you are right about the do-while construct if it shows allocated as equal to c it should stop.

verruckt24 438 Posting Shark

Yes agreed, but shouldn't it be static to be directly called using a class name.

verruckt24 438 Posting Shark

But for that too computeArea() should be static.
OR
It should be called with the object name (cir) casted to child.

verruckt24 438 Posting Shark

For the line, abstract1 cir = new child(); :
Cannot find symbol
symbol: constructor child()
location: class child

Here, you are creating a new child instance alright, but there is no such constructor for the child class.

For the line ,child.child(side); :
Cannot find symbol
symbol: method child (int)
location: class child

Here again, you are caught calling a method in the child class that does not exists. Yes you do have a method public child(int side) but let me tell you that since this method shares the name of the class it becomes a constructor. Also the way you are calling it, with directly the name of the class as a reference, it needs to be static.

Also keep in mind the casting masijade tells you about.

verruckt24 438 Posting Shark

.For this simple questions

Thats exactly where my previous post targets, if you think this question is so simple, why in the first place do you need others help.

PS : I confess, I only got to know the new keyword in java through your post. Actually to tell you the real thing just because of that I never created any object in the Java language all this while. but I hate you for spoiling my cover-up and also really hope that someone posts the correct answer to this question, cause, psst...be silent, I am going to need some objecst in my upcoming project. ;) I really hope my boss isn't on daniweb. :(

javaAddict commented: Excuse me, what is an Object? :) +5
verruckt24 438 Posting Shark

Sei nicht so hart man, jeder fängt mit dem gleichen Scheiss an...

Dont be so harsch on the poor guy. We all started with such trivialities...

I don't know about you, but atleast I did not post on a forum for a for loop construct for any of the four programming languages I have learnt and also I assume none of the others who have posted here, did that. And if you think I was being harsh on him for asking help for such a trivial thing, then harsh I am, because I believe that if you are screwing up on something and nobody even bothers to tell you that, then it means that they have given up on you. Sometimes you need to take up the initiative and show a practical mirror to someone who badly needs it.

verruckt24 438 Posting Shark

@nandomendonza : I would like to ask one question of you first. Have you been taught the for loop in the class (I assume you are in a class since you mention the word instruction) where you got this instruction.
If yes, do you think it is so tough, after knowing how a for loop functions, to implement both the instructions, that you post it in a forum ? Both the for loop constructs could have been built before you completed writing your post.
If no, then I suggest you ask your instructor for the same. Then try it on your own. In no programming language a for loop construct is such an uphill task that you won't be abe to do it, if you really make up your mind. Not to mention that even an uphill task would not remain that impossible if you make up your mind on it.
It's my appeal to all the beginners here, through this post that you are supposed to try such things on your own. If you are struggling to get it correct, even after a week's time - and a week it should be - then you could may be make up your mind whether to post the problem on a forum or give up programming altogether, and believe me if you are struggling to write a for loop construct for a week the latter isn't a bad option at all.

Edit : I mention a week's …

ddanbe commented: You can say things very well +4
verruckt24 438 Posting Shark

Why don't you look it up on the internet. Try finding answers to such questions by searching them on the internet, instead of asking forum members. This will save you time too as also you would have the oppurtunity to learn something else with that.

froppy commented: Unhelpful. Always answer instead of referring elsewhere for the people who get to this page by searching. +0
verruckt24 438 Posting Shark

Because you ask for a fancy way, I give it to you. So suppose you want to allow multiple answers without much work you can do this :

Scanner input = new Scanner();
String response = "";
System.out.println("Do you want to continue ?" Yes/Y/No/N);
response = input.nextLine();
do{
// Whatever you want to do
}while(response.toLowerCase().indexOf("y") != -1)

Now your program won't stop for any answer like Yes, yes, Y, y, Yeah, Yep, Why not, and also for ones you say yse,sey,eys,esy (mispellings) - Howzzat ?

Okay that was certainly a funny way of implementing it, only becuase you asked for, but on a more serious note, you should put the conditions, for which you want to allow the user to move ahead, in an OR clause, such as this :

while(response.equalsIgnoreCase("Y") || response.equalsIgnoreCase("Yes"))

You would ask here - what about the mispelled responses ? - Well in that case tell the user about the valid inputs. Ask him once more what he intends to do, may be he will not do the mistake again. The point here is to make sure that the user knows what he is doing.
To prove this point let's take the above example. Say that you have prompted the user with "Do you want to continue ?" in the above case and are waiting for his response. The user types, say, "Not yet" which certainly means he is not ready for giving you an input at this very moment, but the …

Antenka commented: Wow! Impressive speech :P +2
verruckt24 438 Posting Shark

This is because your system is not able to locate java.
Here you have two options :
1. Open a command prompt window. Then write set path=%JAVA_HOME% where JAVA_HOME should be your path to the bin directory in your java installation. So, say for example you have Java installed in your C:\Softwares\Java directoryyou should put the path as set path="c:\Softwares\Java\bin" 2. The option above has to be done for every new shell. Instead of that you can do with a permanent option which is by adding the same java installation path to your PATH Environment Variable.

verruckt24 438 Posting Shark

There's one more thing, that you have been forgetting and which I too skipped in my first post. Should you not reset the index too to zero so that the entire array is scanned once again. What say ?

verruckt24 438 Posting Shark

take a look at the found1 variable, at first it is false, then when you enter a number that can be located in the array it becomes true

found1 = true;

but then you do not set it to false again before checking for the second number. Then your while loop checks if found1 is false, sicne it is true !found1 returns false and the control would never enter the loop again.

This is what the first impression I get from your program where you might be going wrong, if thats isn't it, let me know.

verruckt24 438 Posting Shark

There is also a forum for JSP here. We would have liked you searching a bit and getting to know the place before posting directly. Moreover it's much more beneficial for you if you put this question there as you would get help faster.

verruckt24 438 Posting Shark

There is not much common where purpose of usage is considered for Java and JavaScript though I am sure they share together much history.

Java is a general purpose language for programming client or server side applications. JavaScript on the other hand is a client-side scripting language.

Since you mention you are a beginner siting and example based on usage would make tings a little clearer I guess. Java would most likely be used for developing applications that run on a stand alone PC such as a desktop GUI program. If you are aware of file sharing peer-to-peer applications, LimeWire is one of them. Java is also used to develop applications that run on the server, such applications normally run without much user interaction and continue to run for days or even months on end without being stopped even once. Various services offered by companies to their clients e.g. messaging service fall in this category. These applications are often called command-line based applications as they are started by commands on the command shell.
JavaScript is used to carry out client side programming in web applications. JavaScript code is embedded within HTML pages and runs in the context of the browser. Most web browsers today have built-in support for JavaScript. JavaScript is commonly used for validating informatoin filled out in web forms, though it does have other uses.
Google about both of them for further information.

verruckt24 438 Posting Shark

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.

Yes you are correct, I don't how but the post date somehow skipped my attention here.

verruckt24 438 Posting Shark

iText is a free, open source Java to PDF converter and it offers much more.

verruckt24 438 Posting Shark

can you be more specific, about which language you are talking about as the word "language" is broad

I guess she wants it to be broad. She doesn't want her question to be specific for any langauge.

verruckt24 438 Posting Shark

Can you detail on this and explain with an example cause I somehow get the feeling that I haven't understood you completely.

verruckt24 438 Posting Shark

If you know the elements that classify the range then it isn't too complex, while running through JTable collecting sub-totals you just need to check whether the particular item classifies for the range and if it does you add it's sub-total to the grand total.
If I have assumned something wrong over here, correct me.

verruckt24 438 Posting Shark

Can you define range ?

verruckt24 438 Posting Shark

You need to traverse the queue entirely for that, currently you are just showing the info of the first node.
Do something like this :

public void showQueue(myQueue head){
    myQueue temp = head;
    while(temp != null){
        System.out.println(temp.data.toString()); // prints out data at this node.
        temp = temp.next; // next should be the link to the next node
    }
}

Don't assume my code to be working, rather the opposite, just treat it as a pseudocode for the traversing and printing logic.

verruckt24 438 Posting Shark

When putting an item inside the queue why do you want to show the queue. Or is it some assignment requirement that on every addition of element to the queue you need to show the queue structure ?
If yes, then write some method that traverses the entire queue and shows the data stored ar every location of the list queue.
If not give us details.

verruckt24 438 Posting Shark

@masijade : Yeah you might be correct on this, cause you seem to have had a better look at his code. For me I just gave it a glancing look and suggested him the most outrightly wrong thing that appeared to me. Actually ain't able to take much time out. Also since his code post was huge, I just hurriedly scrolled down through it, without even realizing that you had already made the same suggestion (and more) to him. It's just today when I saw the number of replies to it and carefully scrolled for more replies that I saw your first post on this.

verruckt24 438 Posting Shark

No, I don't think so. The reason is JTable is UI component for the user to view things in a tabular format and not for performing business logic on the values in it.
Since the values themselves might come from a database, you might have the option of getting the sum of the columns from the database itself and then show it in the grand total column.

verruckt24 438 Posting Shark

I am already a spent force with this. But I am still posting this because being a Java programmer my conscience does not allow m to leave a Java learner hanging in the middle like this. Thats also because a part of my mind tells me that you may be really lost and need some help finding your way out.
This is what I meant in my last post, but in simple, modest words.
You are doing this :

Double hoursWorked = input.nextDouble();
      // read value for hours worked
      if(hoursWorkedInWeek <=0.0){
          System.out.println("Hours worked cannot be negative/zero.");

Where you are making the mistake of assigning the input value to hoursWorked and checking the value of hoursWorkedInWeek which you have already initialized with 0. Now I guess there should be no surprises if you get a "Hours worked cannot be negative/zero".

You are doing the same thing with payrate. Assigning the input value to payrate and then checking the hourlyWageInDollars , again I don't think there should be any surprises why you get the reply.

So in essence, you should be doing this:

Double hoursWorkedInWeek = input.nextDouble();
      // read value for hours worked
      if(hoursWorkedInWeek <=0.0){
          System.out.println("Hours worked cannot be negative/zero.");

instead of

Double hoursWorked = input.nextDouble();
      // read value for hours worked
      if(hoursWorkedInWeek <=0.0){
          System.out.println("Hours worked cannot be negative/zero.");

and this

Double hourlyWageInDollars = input.nextDouble();
      System.out.println();
      if (hourlyWageInDollars <=0.0){
          System.out.println("Hourly wage cannot be negative/ zero.");
      }

instead of

Double payRate = input.nextDouble();
      System.out.println();{ …
verruckt24 438 Posting Shark

You should go bald I guess.

Double hoursWorked = input.nextDouble();
      // read value for hours worked
      if(hoursWorkedInWeek <=0.0){
          System.out.println("Hours worked cannot be negative/zero.");

This is the height of being careless, really Coyboss, this is what exactly stephen84s was trying to tell you yesterday and I mentioned the same. Just check what variable you are reading and what variable you are comparing. And you don't stop at once you go on and do it twice.
Here it is

Double payRate = input.nextDouble();
      System.out.println();{
      if (hourlyWageInDollars <=0.0){
          System.out.println("Hourly wage cannot be negative/ zero.");
      }

You have not even taken care to change the variable names have given to you, thats how careless you have been and when somebody points that to you, you try to get back at him.

stephen84s commented: Finally someone noticed what I saw in him at the start :P +5
verruckt24 438 Posting Shark

I assume you have rows of JTable filled with different such orders having the attributes you just mentioned, each with a subtotal of it's own, you now have to make a grand total summing up all the sub totals.
To do this you would have to run through the JTable collecting all the subtotals and keeping on adding them to get a grand total, I don't think there's an automated way to do that.

verruckt24 438 Posting Shark

I haven't gone through the entire program of yours, no need to even, since there is much of repeatition. But what I have gathered from a quick look is that you need to avoid making all those classes. You are doing the same thing in all of them. Why not then make 25 instances (threads) of the same class. You can pass a parameter to the thread specifying the IP range it needs to scan.

verruckt24 438 Posting Shark

I would like you to detail on your question. What do you want to do exactly when you say that whether the items cadn be added up?

verruckt24 438 Posting Shark

Setting the rows and cloumns alone will not get the scroll bars for you, if you read my earlier post carefully, I have mentioned there that setting the Rows and Columns for the JTextArea will set the total size of the JTextArea, where Rows will specify how many lines of text the JTextArea will allow and Columns would specify the number of characters per line.
Now when your text runs beyond the viewable are of the JTextArea and then scroll bars would appear on their own for you to view that text.
Try this and see.

verruckt24 438 Posting Shark

@Coyboss :
You need to put the two the other two 'if' statements immediately after the reading of the two values and the break statement needs to be in the first if. So your code should take the form similar to this:

while(true){
    System.out.println("Enter employee name : ");
    // read employee name
    if(employeeName.equasIgnoreCase("stop") )
    break;
    
    //read value for hours worked
    if(hoursWorkedInWeek<=0.0){
        System.out.println("Hours worked cannot be negative/zero.");
    }
    else{
         // read value for payRate
        if(hourlyWageInDollars<=0.0){
        System.out.println("Hourly wage cannot be negative/zero.");
        }
        else{
             // calculate and show the Weekly pay
        }
    }
}
verruckt24 438 Posting Shark

I dont want to be rude either but
I OBVIOUSLY DON"T KNOW WHERE IT NEEDS TO GO!!!!!

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

Or do I need to keep guessing?

I have been working on it for over 2 hours and tried it in numerous places including AFTER MY PROMPTS to INPUT and still NO JOY!! I am STUMPED, that is why I asked for help!

@Coyboss:
You cannot be rude to someone you asked the help of in the first place. Yes it's obvious that you don't know where it needs to go, but stephen84s did enough to drop you hints in his posts, I don't want to judgemental here, but I suppose you should have found a way out of your program if you had picked the hints. You did not do that. Let me tell you something, you cannot be expecting spoon feeding over here, it's okay everybody needs help, but that doesn't mean that you will be served the answer on a hot plate. I do understand that you have been towards getting this working for you for long, but getting back unnecessarily at somebody who is trying to help you isn't going to help you either. He was trying to help you, when you did not concentrate on his hints now wasn't he?

verruckt24 438 Posting Shark

Firstly, you haven't called the method spalsh() , though this won't in any way affect the working of your code, but just mentioning the fact. So you should include a statement such as this as your first statement in the main method.

splash();

Secondly, you say the program stops after requesting the three inputs from the user, but haven't you written it that way? You haven't made a call to the calcFV method after asking for the input. So do that.


Also since you are printing out the futureValue in the calcFV method itself, you can opt out returning it with the return statement but if you absolutely want to, you will also have to accept it in the statement that calls the method.

So after making the changes I have suggested you. your program should have a form like this.

import java.util.Scanner;

public class HW02_jsn{
    public static void main(String [] args){
        splash(); // show information about the program's task.
        // the three input requesting statements, with the user input scanning stmts in between them.
        double futureValue = calcFV(p,r,t); // this futureValue is different than the one declared inside the method calcFV
        System.out.println("Value is " + futureValue);
        // splash code here
        // calcFV code here
    } // end of main
}// end of class
zaraeleus commented: You have been very helpful and patient with me. I appreciate that very much! +1