202 Posted Topics
Re: It looks like the author of the code you found is doing something slightly different from [URL="http://5dspace-time.org/Calendar/Algorithm.html"]this algorithm[/URL], but only slightly. This might help you understand what the code is doing. | |
Re: 1. you misspelled array.length in your for loop 2. in your print statement, use the variable i instead of the constant 0 [CODE] System.out.println(array[i]); [/CODE] Also, in your displayName method: 1. Move the declaration of [icode]int i = 0;[/icode] outside of the while loop (before line 13) 2. Move [icode]i++;[/icode] … | |
Re: You need to implement MouseListener to see if the mouse button has been pressed, and you need to implement MouseMotionListener to keep track of where the mouse cursor is on the screen. | |
Re: 1. Create a boolean variable found and initialize it to false just before your loop on line 90. 2. Replace your print statement on line 92 with these 2 statements: [code] found = true; break; [/code] 3. Get rid of lines 94-96. 4. After the for loop ends, put your … | |
Re: Without trying to write Java code, can you write an outline (in English) of what your program needs to do? You can number steps like this: 1. Open the input file for reading 2. Read a line from the file ... What needs to be done for each line in … | |
Re: Also method1 doesn't have a return type. If you don't intend to return anything, make it void. | |
Re: In your MatchApplet class, create a public method called get2DArray, or getMyDouble, or getResidueScores - something that makes sense in your program. The method should be of type double[][], and should return the variable called mydouble. If mydouble is a static array, then the method can be static too. If … | |
Re: Scanner can not only read lines from a file, but it can also be used to parse a string. You could create another Scanner called parser outside of your loop and use it inside your loop to get the data from the input line like this: [CODE] parser = new … | |
Re: Since LetStatement takes a single character variable name and since the variables array in ProgramState is 26 integers, I would assume that each variable is a letter of the alphabet and you need to map letters to integers 0-25. That way there's no need to store the variable names in … | |
Re: 1. Please wrap your code in code tags 2. Post the text of the error message | |
Re: Start by taking the description you posted and breaking it down into a number of steps you need to accomplish to solve the problem. For example: 1. Get player to set min & max values 2. Generate random number between min & max 3. Get player to make a guess … | |
Re: It's hard to know exactly what's going on since you didn't include your WorldOfWarcrap class, but in method fightToTheDeath on line 122, you call [icode]opponent.attack(RPGCharacter);[/icode]. Do you ever initialize the static variable RPGCharacter? Perhaps you should pass the keyword [icode]this[/icode] instead? By the way, it's generally not a great idea … | |
Re: Typically a menu item's action is handled in some Action class (extends AbstractAction). So you might have one class called something like BuildTabbedPaneAction that extends AbstractAction and another called BuildInternalFrameAction that also extends AbstractAction. Each of these classes implements the actionPerformed method to "do its thing". When the Actions are … | |
Re: It is a bit confusing at first, but when you reference source files (.java) in packages, you use slashes, and think of the packages like directories or folders (which they are). When you are dealing with class files, you use dots instead of slashes. | |
Re: A Scanner can be used to get keyboard input from the user. I think you want to analyze, tokenize, etc. the user input, not the Scanner object itself. Try this: [CODE] Scanner in = new Scanner(System.in); // better name than asdf System.out.println("Enter some text."); // good idea to prompt for … | |
Re: Methods settotalPrice() and settotalPriceWithTax() are both type double, but neither one has a return statement. | |
Re: I don't think hashtable is the correct structure for the data you are trying to store if you are just using a string for the key and a string for the value. In a hashtable, the keys are supposed to be unique for each unique record, but in your post … | |
Re: Not sure what you want to do in the loop, but maybe the Start button should start a new thread, and the Stop button can stop it? See [URL="http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html"]this link[/URL]. | |
Re: Are you trying to append to the end of the existing file? If so, see this link: [URL="http://www.artima.com/forums/flat.jsp?forum=1&thread=118486"]http://www.artima.com/forums/flat.jsp?forum=1&thread=118486[/URL] Not sure it that's what you're looking for... | |
Re: No, you don't have to do both things in just one class. Which class has a main method? Inside main you will construct instances of both classes, and then you can put them together (add the form to the window). If you don't understand this, post your code (using code … | |
Re: Do you know what line of code is causing the exception? Try doing e.printStackTrace(), rather than System.out.println(e.getMessage()). | |
Re: ??? I don't know why ceyesuma is talking about XML here. ??? javanew, when you say your code "doesn't work", what do you mean? Are you getting an error when you compile? When you run? Is it not doing what you expect? If that's the case, please describe the program's … | |
Re: Are you getting a syntax error? What is the error? We can't help you understand the errors if we don't know what they are. Please post you code in code tags next time. | |
Re: You need to make some effort yourself first before anyone here will help you. This forum is not a place to find someone to write code for you. | |
Re: [QUOTE]location: class javaapplication18.compteBancaire[/QUOTE] For some reason the class in the error message starts with a lower case 'c'. Check your file name - it must match the name of the class, and case matters. | |
Re: According to your date formatter, you are expecting month to come first. 13 is not a valid month. | |
Re: Your question is unclear. Can you give more detail about what you're trying to do? | |
Re: Here is your code fully parenthesized and inside code tags. [CODE] public boolean isLeapYear() { if (years % 4 == 0) { if (years % 100 == 0) { if ( years % 400 == 0) { return true; } else { return false; } } // what should be … | |
Re: The error says your problem is at line 149 in ImagesTest.java: at ImagesTest.RefHist(ImagesTest.java:149) But I just ran your code and did not get the error. Did you try running it again? Do you always get this same error? | |
Re: The problem is the for loop. Before it executes, loaded=0 so there's nothing to draw, and after it will be something like 1000000001. Only then will the bar be drawn again. | |
Re: 1. You are calling calcSum 3 times (lines 21, 22, 28). You should only call it once (line 28). 2. On line 22 you should just refer to the static sum variable rather than calling calcSum again. 3. Since you have sum as a static variable, you don't need to … | |
Re: 1. Your code isn't in a method. Try putting it in a main method. 2. You have the array fileslist declared twice: on lines 6 and 12. Change the declaration on line 6 to [CODE] String fileslist[] = null; [/CODE] and change line 12 to this: [CODE] fileslist = directoryOfTxts.list(); … | |
Re: Yes, you should be able to read a directory without putting your program in that directory. If you are able to list the files, you should also be able to access those files, but you need the path to the files in order to process them. It looks like the … | |
Re: See [URL="http://download.oracle.com/javase/1.4.2/docs/guide/awt/demos/lightweight/RoundButtons/actual/RoundButton.java"]this link[/URL]. It doesn't do the mouse over bit, but it does handle the click, so it should get you started. Also, the code just draws a circle for the button, but you can change the paint method to draw an image, something like this: [CODE] class JImageButton extends … | |
Re: I don't see any output. How is it telling you the total? The loop that is supposed to go for some number of years will only every go one time because year is set to 0 and lcv is also set to 0. | |
Re: If your class doesn't have any constructors, then Java will supply a default one with no parameters. But as soon as you supply a constructor, Java no longer supplies any. So if you want to be able to construct a Car with no parameters, you have to supply a constructor … | |
![]() | Re: I'm not sure I get what you're asking but if you want a menu to print out, something like this: 1. Forward 2. Backward 3. Forward Global ... etc. Then you need to put your print statements before the switch statement. You say this worked with an if/else statement, but … ![]() |
Re: Look up the documentation for the Math class, which has the trig functions you are looking for, in addition to square root and exponent functions. If this is not enough help, ask a more specific question. | |
Re: Use a good code editor to help you find where your bracket error is. And please use the code tags next time you post code. | |
Re: What is the value of numMonths? If it is 0, the for loop won't execute. | |
Re: Sorry, AaronLLF, it looks like no one here knows how to help you. Try searching google or post your question on a different forum. | |
Re: [URL="http://www.example-code.com/java/javaftp.asp"]http://www.example-code.com/java/javaftp.asp[/URL] (Google search terms: java move file ftp) | |
Re: You could write a boolean method that loops through your array, since for every card you're checking the same condition. Then your if statement becomes just a call to that method. | |
Re: You need to make an effort on your own before people here will help you. Have you written any code? If not, give it a try yourself. When you have some code and you are stuck, then post the code along with a more specific question. | |
Re: In java, curly braces { and } define what is known as scope. When you declare a variable, the nearest curly braces define the variable's scope, and the variable is not visible outside that scope. You have code that looks like this: [CODE] if (machine == 1) { char m_weapon … | |
Re: Each place where you see in.nextDouble();, that is where your program is trying to read input from the user. In general it is bad form to have an input statement without an output statement to prompt the user first. So just before lines 4 and 8 I would insert a … | |
Re: The comment above your loop says you are inserting a character into the array, but inside the loop all you are doing is printing out the array. Where does the character get inserted? Your code to print out the array looks fine by the way. | |
Re: Are you saying the blank spaces are required? Would the date 01/23/10 be invalid? A space character can be represented as ' ', or as a string, it would be " ". The slash character is just '/', or as a string it would be "/". Does that help? I … | |
Re: When you use System.out, you are using println, which prints the string and then a new line. But when you use out to print to the file, you are only using out.print (line 131). Change this to out.println to get each line of text on a new line. | |
Re: 1. remove the last character from the input string 2. create a new string consisting of that last character 3. to the new string, append a recursive call of your function with the rest of the input string minus the last character Note that you will need to figure out … |
The End.