1,678 Posted Topics
Re: Your project description literally tells you exactly what you need to do. Create an array of ten integers. Every time you see a 0, increment array[0]. Every time you see a 1, increment array[1]. Etc. | |
Re: You're going to have to choose a language and begin learning the basics of that language. Regardless of what language you choose, you will have to learn about loops such as for loops, while loops, do while loops, etc. And of course, if statements, if else statements, etc. Once you … | |
Re: Private and Public should be changed to private and public. They are supposed to be lowercase - I think it will give you a compiler error otherwise. | |
Re: JoCamps is correct, as a hint for how to display the array backwards, consider writing a for loop that starts at the ending index of the array and goes backwards, printing out the element at each index. | |
Re: And what is your question? You said you can't figure out how to display the header only once. What do you mean by that? Because you said 'header' on the one hand, on the other hand, the only area where you are really displaying stuff is the JTextArea, but that … | |
Re: [url]http://java.sun.com/docs/books/tutorial/essential/io/rafs.html[/url] RandomAccessFile will allow you to read from the file but it will also allow you to access it at any point in the file, which it seems you already know. I don't see anywhere where you are *only* trying to read from the file (and if you were trying … | |
Re: You can find all kinds of information on these on google. Top down is typically thought of as breaking your problem into subproblems, then breaking these subproblems into further subproblems until you have methods/functions that do one thing well. Bottom up is a bit harder to explain, here is a … | |
Re: [QUOTE=nblue;1011410]a website would store prices on their own database so that people can't mess with the price. [/QUOTE] Professional sites will do that. For example, you aren't going to catch websites for companies like best buy or online businesses such as Amazon that don't check the price against their database … | |
Re: You would need a static class variable called 'numberOfBooks' declared as an int and you would simply do numberOfBooks++; every time you added a book to your collection (or whatever causes you to want to increment that category). | |
Re: if ((col >= 19 && row < 16 & col >= 21 && row < 18 && col >= 25 && row < 22 && col < 27 && row < 12 && col < 29 && row >= 8) { row < 16 & col >= 21 will not … | |
Re: [QUOTE=JugglerDrummer;1011276]where's ProductDB.inventory declared? you can't just start referencing variables in a function when they were declared in main. You might want to pass it as an argument or declare it somewhere else. :D[/QUOTE] ProductDB is a completely different class than ProductApp, and inventory is a variable in ProductDB that is … | |
Re: You just want to count how many times a value is in the linked list? If so, I don't see how your method could work. if (x.value != value){ return 0; } The first time the value isn't at the node, it will stop, even if the value is found … | |
Re: angle in degrees = angle in radians * 180 / Pi Use that formula to fix the output. Or to fix the calculations in your code, wherever your miscalculations may be if you have any. | |
Re: Yes. If you have a GridLayout for your JPanel, and you want to change it so that it can display 2x2, you can use the GridLayout class methods to set it that way. [url]http://java.sun.com/j2se/1.4.2/docs/api/java/awt/GridLayout.html[/url] Look at the setColumns method and the setRows method. If you [I]don't[/I] currently have the JPanel … | |
Re: As you said yourself, "I have a program called IstackInterface.java" . . but in your IArrayStack class, you called it IStackInterface. The two are different because of the capital 'S'. Rename it. | |
Re: To do that you will essentially need a ton of logic. For example, 717 would print out seven hundred seventeen whereas 707 would print out seven hundred and seven. You would have a bunch of cases like this. You could begin by examining the similarities instead of the differences: For … | |
Re: [QUOTE=Superfat;1008600] Where object1 is the variable. I tried doing that, but i get an error ")" Expected on that line, i suspect that it is because anything that is expected in that first slot is expected inside of quotes.[/QUOTE] Incorrect. Anything in that first argument has to amount to a … | |
Re: What is this? "addMessage(java.lang.String Why is this so confusing, int xPos, int yPos)" java.lang.String why is this so confusing does not mean anything. And if you are declaring a method, you cannot do so inside another method. 'main' is a method. You can only declare methods inside of your class. | |
Re: It seems like you already figured out how to get the Characters from the ArrayList and compare them to see if they are the same. Now all you need to do is write a for loop that prints from 1 . . n where n is the number of elements … | |
Re: . . What? You'll have to rephrase whatever you just said. Sorry. | |
Re: So a Java interface is more important than a Java Object in your opinion? Since the purpose of object oriented programming is to use Objects? If you are talking about interfaces in general then I take that back, but you specifically mentioned Java interfaces. . | |
Re: I don't do these conversions the way you do, I do it the first way that is shown on this link. But your way is described there as well if you're having trouble with it. [url]http://www.wikihow.com/Convert-from-Decimal-to-Binary[/url] | |
Re: Put in a main method where you think it should go, then repost your code. Also, you posted two classes in one code block. . I hope that your classes are defined in separate files. You can't define two classes (i.e. your car class and your Inventory class) in the … | |
Re: You created an inner class that implements ActionListener, and you defined the actionPerformed method for that inner class. But when you make the following statements: [CODE=Java] Chapter165 listener = new Chapter165(inputMile, outputKm); inputMile.addActionListener(listener); outputKm.addActionListener(listener); [/CODE] "listener" is an Object of the class type Chapter165. But in the Chapter165 class, you … | |
Re: We don't do people's work for them. If you read the stickies, you'll notice that we're here to help people learn how to do things themselves. Also, since AVL trees are a data structure, I'm sure google already has the wonders you are looking for. | |
Re: It's tricky to help you with this without just giving you a working code sample (which is against the rules here). My first attempt would be a little different than nomemory's. . [CODE=Java]public int getListCount(ArrayList list){ int count = 0; for (every object in list){ if the object is an … | |
Re: [QUOTE=StarZ;1007722]So basically like just copy all the code that setBase had, and put it in with height? I don't mean replacing it I need the two methods. But when I put them together like im pretty much repeating the codes accept one is for base and one is for height. … | |
Re: Then convert the meters into centimeters by dividing height by 100. Then do the same calculation that you already posted. | |
Re: Vernon and previous posters are correct, keep in mind that the toString() method is usually used to display some description of an Object. You would write your own toString() method if you wanted to do just that . . for example, if you were writing an RPG, your toString might … | |
Re: And as far as I know a wsdl file defines the types of requests that can be made to a web service and the types of responses that will be received for those requests. I could be wrong about that, though. And what do you mean by creating a web … | |
Re: As far as I recall calling super.paintComponent is going to clear the surface that you are painting on, which is not what you want to do, so I'd erase that line of code. Recompile&run, then tell me what happens. | |
It took me very little effort to put a JComboBox in a JTable so that when the cells in a certain column are clicked, it lets the user choose from a drop down list of items. However, my program requires that the underlying combo box can change, since the list … | |
Re: What do you mean it won't run because of "public class Calc extends JFrame implements ActionListener"? It looks to me like that is a correct class header, although I haven't written a Java program in awhile. What is the error message the compiler is giving you? Also, you declared your … | |
Re: Yes, you just plug in the numbers. You'll see that when you plug in n = 3, the first part of the formula immediately becomes 9*T(1) so you're practically already done. | |
Re: Your link to Heisenbugs doesn't exist anymore or was linked incorrectly. [url]http://en.wikipedia.org/wiki/Unusual_software_bug[/url] | |
Re: To elaborate on what llemes said (and he is correct), you are trying to use the following method "public Object[] toArray(Object[] a)" which takes an array of Objects, but you are passing in an array of chars. "char" is a primitive type, not an Object, which is why you are … | |
Re: Since Ezzaral already answered your question - doesn't your code have syntax errors? You didn't specify a type of Exception in the catch block i.e. catch(Exception e). PS, for things like this, usually the best way to find out is to run a small sample program and see what the … | |
Re: Monte Carlo isn't a method, it is the set of algorithms that use repeated random sampling to compute their results, according to wikipedia. So my question is: if that is the case, then don't you have to design an algorithm to estimate the # bottles of Boost before you even … | |
Re: [url]http://www.google.com/search?q=java+image+on+JPanel&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a[/url] There are a ton of examples on the web. . "window" is either a JFrame or JPanel though, and Image is the name of the Java class. You can also check out the java tutorial on Images. . [url]http://java.sun.com/docs/books/tutorial/2d/images/[/url] | |
Re: Just use a for loop that cycles through the entire String one character at a time. for (int i = 0; i < string.length(); i++){ 1. get the current character 2. attempt to parse this character into an integer. 3. add the integer you just parsed into the linked list. … | |
Re: You'll need to clarify your question. Since the JTextArea displays text, I'd imagine it would go something like jTree.getItemAt(index).toString() or something like that. Then you'd append the text to the JTextArea using whatever the correct method is (probably append) | |
Re: Yeah interfaces are somewhat similar - if your class "implements" the interface, it forces you to include those methods that are defined in the interface itself. | |
Re: I could be wrong, but my best guess is that if you want to change the file's last modified time (to something arbitrary), this would be OS dependent. edit: sorry, just realize that doesn't really help you very much either way. Tired over here, I was pretty much thinking out … | |
Re: If you add components after your GUI is initialized (which it looks like you're doing) I think you need to call revalidate() or validate() on the JPanel or JFrame. If you read the revalidate method documentation it might make it clear which one needs to happen, if at all. Or … | |
Re: Whenever you do projects like that you should consider all of your options: for example, is your input file guaranteed to input only integers or characters? If so, you could quit on any input that is not an integer, and this would be no different than quitting when you see … | |
Re: Either use wikipedia or ask a more specific question. I don't mean to be rude, it's just that any information I can provide can just as easily be found on wikipedia - I just checked the articles out and they aren't very confusing, but if you have any more specific … | |
Re: One thing I noticed right away is that your insertAtIndex function does not have a for loop. If you want to insert a node at the fifth index, then you will need a for loop and you will have to go to the 'next' node four times. (It looks like … | |
Re: [QUOTE=Trekk;993144]I placed the loop in there to keep the program "asking for inputs" until a condition was met (i.e. User inputs 'E' or 'e'). But obviously i might have missed something[/QUOTE] Yes, but a while loop runs until the condition is no longer true. For example: [CODE=Java] int i = … | |
Re: What the poster above posted might look confusing, but what he is saying is a good way of doing this: Each String in the array will be the "name" of the index it is at. So index 0 of the array is named zero, and so on. This means in … | |
Re: Black box testing would involve trying to break your code by giving it invalid inputs and making sure it handles them appropriately, as well as giving it valid inputs and making sure it comes up with the right result. So I do not think your code counts as black box … |
The End.