7,116 Posted Topics
Re: You have a single quote at the end of line 43. For the corect syntax of a switch, with examples, see the Oracle tutorial page [here](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html) ps: You keep creating new instances of Scanner. That can cause problems with text buffers getting lost. Just create one instance when the program … | |
Re: > How can I check the Java version from command line. `java -version` | |
Re: Your answer is 9 years too late, adds nothing to the discussion, and is one of the worst pieces of code I have seen in some time. You obviously need to study boolean values some more becuase testing a boolean for true is such a novice mistake. The whole of … | |
Hi Guys. I knw what I want to achieve but not how to achieve it! Any hints would be gratefuly received, or, if it's not possible, tell me so I can stop trying. I have an internet connection -> router with NAT, DHCP etc -> LAN with all kinds of … | |
![]() | |
Re: Looks like the loop on line 17 will never terminate because the exit condition on line 20 is wrong. Review the documentation for the abs function,, then ask yourself how can that return a negative value? | |
Re: Why the redundant tests? Line 4: we know that i<60 because of the if test in line 2, so that part of the test is redundant. Ditto the <45 on line 6 | |
Re: There's not really any "organisation of values" required in this spec. You have 4 values as parameters and all the if tests use one or more of those values. Can you explain your concern in more detail? | |
Re: Me too (Apogee Duetta Signatures bi-amped with Quad 606Mk2s and custom crossovers) | |
Re: It looks like your problem is lines 26/27 where you try to get the text from the text fields. The variables jtf3 and jtf4 are private to the ChuaWeiheng class, so they are not accessible in the Comments class. The simplest fix is to make Comments an inner class of … | |
Re: Q: "I want to learn first aid" A: "I suggest you start with brain surgery" C++ is a nightnare agglomeration of everything that is difficult from every other language. Definitely not for beginners, nor (IMHO) for anyone else. Almost any modern language would be a decent place to start. Loops … | |
Re: Why are you using an ObjectOutStream? Those streams write data in a binary format that only ObjectInputStream understands (see excerpt from API doc below). Scanner expects data as simple text, so to create a file that it will understand you need a PrintStream to write simple text. Or simply create … | |
Re: what help EXACTLY do you need? | |
Hi Guys. I'm getting bored, and so I'm looking at Python for a new challenge. I hoped to be able to use my Java NetBeans IDE to avoid an IDE learning curve, but it seems that NetBeans support for Python died years ago. So, all you Python gurus... what do … | |
Re: radiusF has to be a variable fro this program, but PI is probably the obvious constant from the java.util.Math class. You can only make an unqualified reference to it like that if you have `import`ed it at the beginning of the source file. | |
Re: Yes. If the `names` array is the same size as the `x` array (as seems probable) then in that loop j goes from 0 to `x.length-1`, so the `[j+1]` index will go out bounds on the last pass of the loop. ps Oracle's and Apache's Java coding standards prefer `String[] … | |
Re: What's the most efficient algorithm you have come up with so far? (Pseudo-code or plain English will do... you can't start coding until you know what the algorithm is.) | |
Re: Please re-read my previous answer to you. You need a [Comparator](https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort(T[],%20java.util.Comparator)). Arrays.sort(array) without a Comparator only works if the contents of the array have a "natural sort order" (eg ints) or are Objects that implement the `Comparable` interface to define their natural order. In your case you have a nested … | |
Re: Hi It looks like you are going about the transfer/print thing in a way that's making your life harder. In best OO style you should get rid of those two methods and put function where it belongs... You seem to want to show the rank as "Two" ... "Ace", so … | |
Re: How about ANDing it with 0xFFFFFFFE for even, ORing it with 0x00000001 for odd? | |
Re: Netbeans support for C++ was going to be released in version 11.3 but it didn't make it Maybe it will be ready for use in 11.4, maybe not. Anyway, you need to select a different IDE for C++ right now. | |
Re: > Since when is this site helping scholars with their homework? Since forever. We have always been ready to help people learn by explaining where they have gone wrong, or providing guidance when they get lost. BUT we insist that they first show some effort themselves. We never do homework … | |
Re: By your definition Java, not producing machine code, and needing a run-time interpreter for its byte codes, is a scripting language. | |
Re: You need another variable to hold the total price. Set it to zero before entering the loop. In the loop add each result to the total price. After the loop you can print it. | |
Re: That's not declaring an abstract method. Please read the whole thread before posting - it you had then you would know that you have defined an empty method (definition is complete, it can be called, but it does nothing). To declare an abstract method you have to either use the … | |
Re: Hi Rachelle, welcome to DaniWeb. Please take a moment to familiarise yourself with the site rules http://www.daniweb.com/community/rules in particular, don't hijack old threads - start your own for a new question and you must show what you have done so far if you want help with homework. JC | |
Re: Here in France the pharmacist is actively encouraged to dispense a generic when the prescription is for a brand name drug, unless the doctor explicitly states "not substiutable" on the prescription. With effect from this month the state's universal healthcare insurance is limited to the cost of the generic, eve … | |
Re: I hope it happens for you soon as well. Who is the rest of the "we" that you walk with? | |
Re: maybe you need to flush/close the output stream explicitly? | |
Re: You contact the provider to register the product for the new computer. Why is that so hard? | |
Re: Input Mismatch Excption happens because the `nextInt` expects an integer value but the input cannot be parsed as an int. What exactly did you type for the input when you ran the program? | |
Re: Use `JOptionPane.showOptionDialog` with options for True and False. Eg: String[] options = {"False", "True"}; int answer = JOptionPane.showOptionDialog(null,"Java is great?", "Question", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null); if (answer < 0 ) System.out.println("User cancelled/closed dialog"); else System.out.println(options[answer]); | |
Re: You are obviously expected to do some simple validation on the day number - it needs to be > 0 and <= (number of days in that month). You need to design some suitable if tests and insert them after line 2. If you get stuck come back here and … | |
Re: You shoud look at the JavaDoc for Java's HashTable for essential information. The source code for that is also on the web, so you can see how it's implemented (if that helps). Your 4 methods will need parameters - thinking about those will also help clrify things. | |
Re: Hi Unlike certain other sites we welcome and encourage discussion and opinions. Anything goes, just keep it legal and don't insult other members. What would you like to talk about? | |
Re: If you are thinking of setting up an outbound cold calling centre then i sincely wish a horrible death on everyone involved. 10 cold calls a day made my life so disrupted that in the end i had to give up my land line. Cold callers are the scum of … | |
Re: Test early, test often Every requirement document is (a) wrong and (b) incomplete | |
Re: I've always preferred test-at-the-bottom for this pattern - keeps it all more local ... do Get user input Do processing Ask user "continue?" while user says "yes" | |
Re: If you call that method twice you wil get problems. By closing then re-opening a new Scanner on the same input stream you lose all control over what is or isn't in the buffers of each Scanner and/or he underlying stream. Lost input is pretty much guaranteed. The general rules … | |
Re: If you have already created the game then it's too late to worry about requirements. Normally you document the requirements, then design an app to meet those requirements. Not vice-versa. | |
Re: That looks like a lot of complex code to do something that should be simple. Why are you using an AWT Canvas in a Swing application? Why not just a simple JPanel and override paintComponent? | |
Re: > == is a shallow comparison Some spectacular Java nonsense here. The == operator cannot be overloaded and checks for referential identity. If two variables contain the same reference then by definition they refer to the same object, not to two objects, so the nonsense about "shallow comparison" is not … | |
Re: It looks ike there's only a couple of SymPy calls that do anything, so the challenge is simply to replace those two methods. There are a ton of Java libraries for handling matrix arithmetic etc - it shouldn't be to hard to find the required functionality. The rest of the … | |
Re: You could use an ordinary inner class instead of the anonymous event handlers, and pass `i` to the constructor. Something like class MyHandler extends Eventhandler { int i; MyHandler(int i) { this.i = i;} @Override public void handle(MouseEvent event) { UI_SelectionMenu.selectedTile = i; System.out.println(UI_SelectionMenu.selectedTile); } } ... for (int i … | |
Re: You can only get to line 17 if `number` is 1, so having a switch on `number` at line 17 is pointless. Did you mean `number2` ? The switch on line 15 has only one case - what's the point of that? Line 18 is invalid - all the code … | |
Re: There's no real alternative to writing that code. Yu may be able to avoid repeating code for each direction by putting that code into a method you can call repeatedly. | |
Re: Nowhere in the posted code do you call ReadTxt. That;s probably why it's never executed, which is why you don't see its output. See how much better this site works when you give all the relevant info? |
The End.