7,116 Posted Topics

Member Avatar for JamesCherrill

I'm looking for an algorithm, pseudocode or any langauge, to generate random numbers with the following characteristics: integer values in the range 0-n lower values much more likely to happen than higher values, eg prob of 0 is n/(n(n-1)), prob of n is 1/(n(n-1)) - linear relationship between value and …

Member Avatar for invisal
1
668
Member Avatar for jjones0150

It looks like the line causingthe error is line 71 above products=(List<Product>) CollectionFileStorageUtility.load(Product.class); I don't have any info on CollectionFileStorageUtility, but it seems to return a `Collection`. In this particular case the Collection is empty, but that's not a problem. Java is objecting you trying to cast a Collection into …

Member Avatar for JamesCherrill
0
506
Member Avatar for jjones0150

You first need to create an instance of InventoryManager - once you have an actual instance then you can do all the following operations using that instance. eg InventoryManager myManager = new InventoryManager(); ... myManager.addProduct(... myManager.getProduct(... Why does it work this way? - one example would be if you had …

Member Avatar for jjones0150
0
252
Member Avatar for faltu

OK, so you have copied your teachers complete assignment and posted it on a public web site (did you have the copyright owner's permission?). You didn't even bother to explain what help you need. You didn't show the slightest effort to try to do this yourself. I will delete your …

Member Avatar for JamesCherrill
0
172
Member Avatar for altjen

Have a look at Oracle's detailed tutorial on JTables http://docs.oracle.com/javase/tutorial/uiswing/components/table.html in the section on Custom Renderers you will learn how to replace cells in the table with the controls of your choice - in this case you need to check if the cell is in a currently selected row then …

Member Avatar for mKorbel
0
8K
Member Avatar for can-mohan

As you say, in Java Set is an interface for Collections with no duplicates but no information about ordering, so that's completely different from C++ sets which are weakly ordered. (The Java SortedSet interface is one that has ordered elements.) However, some of the Java concrete classes that implement Set …

Member Avatar for JamesCherrill
0
309
Member Avatar for divinity02

I'm sorry, but lines 26-32 are complete nonsense. Just delete them and start again by doing the following: 1. Keep a copy of the requirements in front of you at all time - they should detail the calculations to be done. 2. Give your variables descriptive accurate names - eg …

Member Avatar for divinity02
0
256
Member Avatar for NONONO123

You didn't say which of the many JSONConverter implementations you are using, and the line numbers in your posted code don't correspond to the exception message, but at a guess its the enhanced for on line 20 that throws the problem, implying that postList is null. Maybe you could print …

Member Avatar for NONONO123
0
3K
Member Avatar for prashant_savadi

1. Use ProcessBuilder, which is the more recent replacement for Runtime exec 2. Parse the args yourself and pass then separately to ProcessBuilder, because its default parsing of command and parameters is a frequent source of problems. eg try something like new ProcessBuilder("cmd", "/c", "C:\\file1.bat").start();

Member Avatar for JamesCherrill
0
1K
Member Avatar for Violet_82

Short answer: javafx.application.Application contains all the code for initialising a JavaFX app. the normal main method just calls Application's `launch` method to get JavaFX initialised. Once FX is ready it calls your `start` method, where you do whatever you want. You can think of `start` being to JavaFX what `main` …

Member Avatar for Violet_82
0
345
Member Avatar for Centorpe

The right time to round is when you are converting the floating point value to String - line 1 in the code you posted.Rather than using concatenation to force a default conversion, use String's `format` method to format `(myDiameter - (myPitch * 0.649519))` to the right number of decimals

Member Avatar for Centorpe
0
284
Member Avatar for Centorpe

I don't know android Java, but are you sure isEmpty() will be true if the field contains a blank character as opposed to no character st all?

Member Avatar for Centorpe
0
282
Member Avatar for pihuu

"[Ljava.lang.Object;@64bba873" Is the result of your list view calling `toString() `on your data to convert it to a String for display. That output is the default `toString()` that every class inherits form Object - it just shows its class and hash. You need to make your code more explicit as …

Member Avatar for JamesCherrill
0
164
Member Avatar for mlhazan

You just need to get a pencil and paper and work through the order of execution. Something like... doAnagram(4) calls doAnagram(3) (line 27) before it can call rotate (line 32) doAnagram(3) calls doAnagram(2) (line 27) before it can call rotate (line 32) doAnagram(2) calls doAnagram(1) (line 27) before it can …

Member Avatar for mlhazan
0
253
Member Avatar for prashant_savadi

You need an `InputStreamReader` to read and decode text using UTF-16 encoding. You specify the charset when creating the InputStreamReader, eg `InputStreamReader in = new InputStreamReader(myInputStream, StandardCharsets.UTF_16);` Anything you read from that stream will now be interpreted as UTF-16. Depending on your file's byte ordering you may need to use …

Member Avatar for prashant_savadi
0
271
Member Avatar for divinity02

It won't work because it's too hard to debug. Nobody is going to debug a loop and nested ifs that stretch over 200 lines - it's just too hard. Refactor your code so the outer loop fits on one or two screenfulls. Your objective is to make each block of …

Member Avatar for stultuske
0
253
Member Avatar for divinity02

If x is exactly divisible by y then that means x modulo y must be zero (ie the remainder is zero). Java uses the % operator for modulo

Member Avatar for divinity02
0
233
Member Avatar for divinity02

Around lines 144-146 you seem confused about what variables you are using.

Member Avatar for divinity02
0
319
Member Avatar for priya143

That makes no sense. In Java a string is an internal data item that holds a single sequence of chars A table is either a 2 dimensional GUI component or database table They are completely different things. You can't replace one with the other. Maybe it's an English problem? Give …

Member Avatar for JamesCherrill
0
77
Member Avatar for SasseMan

Here is a brilliantly clear explanation of the difference between validate and revalidate: [url]http://www.jguru.com/faq/view.jsp?EID=88716[/url] @Traps: I don't know why you posted that in this thread, but SwingUtilities.invokeLater runs things on the Swing EDT, and is therefore absolutely NOT intended for "working with large collections of data" - that's a complete …

Member Avatar for Ali_55
0
1K
Member Avatar for Violet_82

How big do you see this file getting? If it will always fit in memory (say just a few hundred meg) then you can do all the appending editing or whatever in memory and re-write the whole thing at shutdown (and at regular intervals). You can get an awful lot …

Member Avatar for Violet_82
0
712
Member Avatar for John_97

OK, some small errors there but it's on the right tracks. What help do you need? If you are having problems declaring subclasses this tutorial may help: http://docs.oracle.com/javase/tutorial/java/javaOO/classes.html

Member Avatar for JamesCherrill
0
211
Member Avatar for AgentOxegen

Your FinalProjectQuestions class is written as if it's a first Java project, not a final. For a final project then you are probably expected to define a class that holds all the information for a face. You create a new instance using the input that you get from the user, …

Member Avatar for JamesCherrill
0
250
Member Avatar for Belfina

No You use names like BookTitle, but you never declare any variables with those names. Everything in Java must be declared. In your constructor you should initialise the variables you declared on lines 2-7

Member Avatar for Belfina
0
273
Member Avatar for miraasir

This is al ablout timing - when things happen. JTextField enterdata = new JTextField(10); s1=enterdata.getText(); This creates a text field and immediately queries it for the text it contains. At this time the text is still "", so that's what yu add to the database. You need to create the …

Member Avatar for JamesCherrill
0
352
Member Avatar for Aeonix

If the program uses the value (and if it doesn't then why have it?) then the program must contain some encoded version of the value and some code to decode it for use. In other words there must be enough information in the program to retrieve the value. So a …

Member Avatar for Aeonix
0
450
Member Avatar for sheelap

The string vaue must be in the range for a byte, ie -128 to +127 (ie -80 to 7f hex). Your value of ac is too large for a byte. If I guess your intent properly, then you can get the result you want by parsing the string into an …

Member Avatar for JamesCherrill
0
192
Member Avatar for zelrick
Member Avatar for coder91

OK, yes you can iterate through the `entrySet()` (hint!). For each entry you can `getKey()` and `getValue() `and test them to see if either is the one you want

Member Avatar for JamesCherrill
0
134
Member Avatar for Amr.Mohammad87

To me it looks like that formula is OK if you number the levels starting a 1, not 0 i level max entries 0 1 2^0 = 1 1 2 2^1 = 2 2 3 2^2 = 4

Member Avatar for Ben McNamara
0
203
Member Avatar for rpv_sen

.java is a source code file so you can't execute it. Yo have to compile it first Compiled java programs that can be executed come in .class files or .jar files If you have a .class file, eg myprog.class, then it's executed by ` javaw myprog` If you have a.jar …

Member Avatar for JamesCherrill
0
250
Member Avatar for mohan@nano

Please don't be upset by jwenting - he's notoriously grumpy. There are many tutorials on how to parse XML in Java - just Google for them. As always, Oracle's own tutorials are probably the most definitive, although not necessarily the easiest: http://docs.oracle.com/javase/tutorial/jaxp/index.html

Member Avatar for JamesCherrill
0
192
Member Avatar for coder91

I tried reading that a few times, but it still makes no sense, and the code you were given (a) also makes no sense and (b) isn't valid code and (c) goes out of its way to break Java naming conventions just to confuse us all. Since both key and …

Member Avatar for JamesCherrill
0
325
Member Avatar for Saboor880

This looks similar to the problem you posted a week ago (column names not recognised). I see that you have not yet marked that one "solved". Maybe you should fix your first column name problem before trying to move on to this one. In any case, posting the wrong code …

Member Avatar for JamesCherrill
0
262
Member Avatar for noobjavacoder

The message is saying: Your `iprint` and `preprint` methods have been defined to require a parameter of type `Node1`, but when you call those methods you call them with no parameters. It's aboslutely pointless trying to execute a program that has compile errors like that. ps: Oxiegen: Where is the …

Member Avatar for Oxiegen
0
422
Member Avatar for AbiSharma

Yes, definitely. Here's how it works: You start by doing what you can. When you get stuck, or if you want a review of what you have done, we will help. The key point is don't expect anyone to do it for you; the more effort you show, the more …

Member Avatar for JamesCherrill
0
63
Member Avatar for sireiz
Member Avatar for Ayoub_1
Member Avatar for mikey3891

To get a floating point division you have to have one or both of the operands to be floating point *before* you do the division. You can make one or both operands `double`, or use this little "trick" int a,b; double ans = a/(b*1.0); // forces dividend to double precision …

Member Avatar for mikey3891
0
259
Member Avatar for ravi raghav

DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there.

Member Avatar for JamesCherrill
0
216
Member Avatar for Saboor880
Member Avatar for kayleigh0411

Thenumbers are normally handled like you are, but when you get an operator you parse and store the previous number then make a note of the operator. Then when the next number is complete (signified by another operator or =) you can parse the seocnd number and do the arithmetic. …

Member Avatar for JamesCherrill
0
1K
Member Avatar for queenofdrama365

1. Unicode is not a byte code. 2. The web is full of examples of how to read a file 3. That's enough. This is not a free "we do your homework" service. We help people who are making a genuine effort, we don't help people who are too lazy …

Member Avatar for JamesCherrill
-1
181
Member Avatar for queenofdrama365

Excellent. You have demonstrated your ability to copy your assignment (did you get the author's permission?) and paste it here. What do you expect will happen next? DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting …

Member Avatar for JamesCherrill
0
212
Member Avatar for Mark_42

Line 23 You are incrementing the final value `Numyears` when you should be incrementing the loop variable `i`

Member Avatar for JamesCherrill
-1
2K
Member Avatar for Farhan_8

Yes Right click in the editor Insert Code... Constructor... click the fields you want to include as parameters

Member Avatar for JamesCherrill
0
209
Member Avatar for Farhan_8

Start with the classes. These come from the problem domain, not from the database or the GUI. Your Use Cases will help.

Member Avatar for JamesCherrill
0
84
Member Avatar for Farhan_8

That seems a decent start. Maybe donor and recipient have enough in common to be subclasses of a Person class? The next step is to take the main use cases and walk through them seeing how easily your classes and methods support the use cases. You may well find that …

Member Avatar for JamesCherrill
0
310
Member Avatar for coder91

Is there a pre-defined set of inputs and corresponding outputs? If so a `Map` would be the obvious choice.

Member Avatar for JamesCherrill
0
222
Member Avatar for ahmed alnaseri

"didn't work"? Means whay exactly? Error message? Listener not called? Listener called but no panel visible? Panel visible but looks wrong? Come on now, give us some info to work with.

Member Avatar for JamesCherrill
0
214

The End.