7,116 Posted Topics
Re: At line 35 you update the settings OK, but you do not update the top5Time array. When you print the results you print them from that array, so the printout does not include the latest value. | |
Re: How about something simpler like boolean isAscending(int[][] a) { int last = Integer.MIN_VALUE; for (int r = 0; r < a.length; r++) { for (int c = 0; c < a[r].length; c++) { if (a[r][c] <= last) { return false } last = a[r][c]; } } return true; } ps: … | |
Re: I had a quick Google, and was struck by how most links were just to stuff about inheritence, polymorphism etc. For me the OO design *process* is about use cases, domain models, class diagrams, sequence diagrams, code. In that order (but iteratively, of course). I haven't listened to all of … | |
Re: It would help if yu posted the actual code. Line 115 you call a method `TopCost`, but you haven't defined any such method. Many of your methods are confusing because they set an instance variable, but they also return that value, and when you call the method you ignore the … | |
Re: No, that's not what it outputs. The actual output is i=1 , j=0 i=2 , j=0 i=2 , j=1 (all you needed to do is to run it) Just step through the two loops one step at a time... i = 0 j = 0 i == j, continue outer … | |
Re: Is this homework? You should know the DaniWeb rules by now. | |
Re: So, if diff is 0 it won't be equal to 'e' or 'E', so the if test (line 8) fails, and you don't issue the prompt. If you always want to prompt the user, why is that if test there at all? | |
Re: There are a few variables that never get any sensible values (eg hours worked, pay rate). It looks like you may have missed the part of the assignment where you were supposed to get those values? | |
Re: "i keep getting an error" tells us nothing. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be. | |
Re: Yes, the constructor is private to stop you using it. The API doc fpr Scanner says: "If this virtual machine has a console then it is represented by a unique instance of this class which can be obtained by invoking the `System.console()` method. " .. so that's the right way … | |
Re: There are loads of tutorials and examples on the web. Nobody here has the time to write another one just for you. Start [here](http://bit.ly/1zHvRH2) | |
Re: That's a good start. You will need to draw the pairs of boxes at the top and the bottom separately | |
Re: Yes (and don't forget exactly 0 or 1 minus signs!). Although in general Exceptions are not recommended for user error handling, this is one of those exceptions to the rule. Even Integer.valueOf(string) does it. | |
Re: Is that all the code? Does the GymMember class have variables for id and weight? Do you set them in the constructor? Is MemberWeight really an inner class of GymMember? Why do you initialise `members` when it's declared, then initialise it again in the constructor? | |
Re: Just FYI - you can also chose what text to show on the buttons, which will make things clearer for the user, eg Object[] options = { "Right Answer", "Wrong Answer" }; .. which you use with the `showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, … | |
Re: What you are describing is a large and complex area, so you will need multiple projects to make real progress. My advice is to start with small simple steps. Pick a simple project from the Projects for Beginners thread, and work through the UML class diagrams all the way to … | |
Re: That message says it all. Why did you think that your vmpr object would be a JFrame? | |
Re: Do you mean a string like "100110001010100..." or an internal binary format such as a array of bytes? If it's a byte[] then you can use a variant of the previous post... New BigInteger(s, 16). toByteArray() | |
Re: One small thing I noticed: line 23 - you return the wrong variable. And just before that the totalsales code makes no sense. | |
Re: A good place to start would be to declare a suitable "2 dimensional collection". Once you know what looks like you can think about how to populate it. | |
Re: Just comparing box2 with box1, box1 has `y0 > 0`, but box2 has `y1 < 0`. Is that right? | |
Re: You can skip to a new line any time by using a \n (newline) character. eg System.out.println("\nHello"); will print a newline followed by Hello Your loop's `end == false` test is only executed at the start of each iteration. So in your second iteration you enter stop, set the boolean, … | |
Re: It looks like your grid is displayed as a grid of JButtons, so do as Phaelax says and set the appropriate icons for each button ... `button.setIcon(icon)` | |
Re: I'll help you to fix it. What exacetly does the compiler error message say? | |
Re: Java has 8 primitive types: byte, short, int, long, float, double, boolean, char. These just have a value - they are not Objects. Their values are primitive values. Strings are Objects - they have instance variables, methods etc http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.1 | |
Re: If there are always 8 items/row then simply divide the item number by 8 to get the row number. Then use modulo 8 to get the position in the row, eg item number = 22 row = 22/8 = 2 (integer divisiom always rounds down) item on row = 22%8 … | |
Re: He has posted eaxctly the same question in the C and C++ forums, where the inevitable downvotes have already started coming in. Not only does he want someone to do his homework for him, but he doesn't even know what language he wants us to do it in. | |
Re: There's no need for an extra `if` Have another look at Slavi's post. If it's still not clear come back here, because there's something you haven't got right yet. | |
Re: That message was generated by some other piece of code - if you don't post that then nobody can help. ps Your sumArgs method makes absolutely no sense whatsoever. | |
Re: Is that access allowed by your security policy? | |
Re: Thanks for that contribution brycematheson. Just two quick comments on the code: Your naming convention is perfectly valid, but not one you will often find in Java - the source code of the API itself is an excellent reference for "standard" coding style in general. You have two buttons that … | |
Re: 30 seconds with the API doc will tell you that the Console class does not have any public constructors. You will also find the following helpful comment: "If this virtual machine has a console then it is represented by a unique instance of this class which can be obtained by … | |
Re: NaN is most commony seen when you try to divide by zero, as may happen if the loop on line 8 above executes zero times, so line 12 is trying to print 0/0 | |
Re: The type E could be anything, String, URL, JButton... so there's no version of the + operator that can be used with all of those. What did you want it to do? o1 and o2 are defined for the abstract 2-arg `plus` method, but not for the 1-arg version where … | |
Re: the ViewManager variable is defined on line 45, inide the do block that starts at line 41, so it goes out of scope when that do block is closed, and cannot be used after that. | |
Re: What code are you using to "use this JLabel in a JTextPane"? | |
Re: Nice scroll bars! What OS is that? Anyway for info on how to set the look and feel start [here](https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html) | |
Re: Repeating the question just wastes everyone's time. Read stultusk's answer, then simply try the code on your nearest computer. When you have done that, if you don't understand what happened, come back here for help. | |
Re: There's nowhere near enough context there to answer the question. What are `round()` and `round` for example? | |
Re: Did you **set** CLASSPATH variable `servlet-api`, or did you **add** `servlet-api` to you classpath? Maybe the problem is that you lost your previous classpath values? | |
Re: I don't understand your question! What do you mean "play the other player"? Do you want to start a new game? If so, you need a second loop, like this pseudo-code do { (here is the code to play one game) prompt "play again (yes/no)?" while (reply is yes); | |
Re: You could store your button references in a 10x10 array (or a 100 element array) as you create them. | |
Re: I think that algorithm will fail if there are both left and right nodes - it will just traverse the left-most children. I think you do need recursion (or something equivalent to recursion) | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here. There are lots of people here who will freely give their time to help you become the best Java … | |
Re: Nice try at some free publicity for your product! I'm sure there's a reason why you didn't mention that it costs between 8 and 12 THOUSAND dollars. Caveat emptor. | |
Re: Java bytes are unsigned 8 bit integers in the range 0-255 You can't use negative numbers with byte values. | |
Re: I doubt that you will sensibly find a better approach than parsing into some kind of RPN then evaluating it from the resulting stack. 100+ lines of code sounds pretty efficient for the complexity of the syntax and operators you are dealing with. | |
Re: There are lots of examples on the web that yu can find with your favourite search engine. There's no need for anyone here to write another one. Anyway - are you trying to learn to write java or just learn how to use the clipboard for copy/paste? Do yourself a … | |
Re: Don't think about code until you have worked out what logic you need. Just get a pen and paper and work through some examples. Keep doing that until you understand how you do it. Test your understanding by explaining it to someone else. When you have done that then writing … |
The End.