7,116 Posted Topics

Member Avatar for hwoarang69

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.

Member Avatar for Traevel
0
251
Member Avatar for hwoarang69

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: …

Member Avatar for JamesCherrill
0
247
Member Avatar for smurfy

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 …

Member Avatar for JamesCherrill
0
234
Member Avatar for rhada79

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 …

Member Avatar for rhada79
0
3K
Member Avatar for Steven_10

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 …

Member Avatar for JamesCherrill
0
278
Member Avatar for jalpesh_007
Member Avatar for rubberman
0
157
Member Avatar for divinity02

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?

Member Avatar for rubberman
0
169
Member Avatar for divinity02

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?

Member Avatar for JamesCherrill
0
278
Member Avatar for jonardy

"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.

Member Avatar for JamesCherrill
0
216
Member Avatar for divinity02

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 …

Member Avatar for divinity02
0
246
Member Avatar for ankit1122

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)

Member Avatar for JamesCherrill
0
151
Member Avatar for sallubhai

That's a good start. You will need to draw the pairs of boxes at the top and the bottom separately

Member Avatar for JamesCherrill
0
305
Member Avatar for FruitPunch

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.

Member Avatar for Freaky_Chris
0
264
Member Avatar for GoneGirl

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?

Member Avatar for GoneGirl
0
165
Member Avatar for jonardy
Member Avatar for GoneGirl

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, …

Member Avatar for GoneGirl
0
139
Member Avatar for smurfy

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 …

Member Avatar for smurfy
0
507
Member Avatar for ali11
Member Avatar for stultuske
0
348
Member Avatar for ezekel

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()

Member Avatar for cgeier
0
838
Member Avatar for divinity02

One small thing I noticed: line 23 - you return the wrong variable. And just before that the totalsales code makes no sense.

Member Avatar for divinity02
0
193
Member Avatar for venkanna39

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.

Member Avatar for JamesCherrill
0
106
Member Avatar for Clyde_1

Just comparing box2 with box1, box1 has `y0 > 0`, but box2 has `y1 < 0`. Is that right?

Member Avatar for JamesCherrill
0
141
Member Avatar for n0tS0av3rag3

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, …

Member Avatar for JamesCherrill
0
139
Member Avatar for My_1

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)`

Member Avatar for My_1
0
697
Member Avatar for sesaso
Member Avatar for sesaso
0
125
Member Avatar for vivekH

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

Member Avatar for JamesCherrill
0
88
Member Avatar for KetraCoder

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 …

Member Avatar for Slavi
0
287
Member Avatar for Amit_25

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.

Member Avatar for Slavi
-1
98
Member Avatar for erictheonly1

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.

Member Avatar for JamesCherrill
0
187
Member Avatar for erictheonly1

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.

Member Avatar for erictheonly1
0
2K
Member Avatar for Jatin_2
Member Avatar for Krazykado

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 …

Member Avatar for JamesCherrill
0
1K
Member Avatar for divinity02

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 …

Member Avatar for JamesCherrill
0
167
Member Avatar for GoneGirl

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

Member Avatar for GoneGirl
0
622
Member Avatar for redtribal23

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 …

Member Avatar for JamesCherrill
0
111
Member Avatar for EarhawkPH

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.

Member Avatar for JamesCherrill
0
241
Member Avatar for samisallaj
Member Avatar for rakibtg

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)

Member Avatar for JamesCherrill
0
167
Member Avatar for rayan22

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.

Member Avatar for Priyanka_9
0
233
Member Avatar for divinity02

There's nowhere near enough context there to answer the question. What are `round()` and `round` for example?

Member Avatar for JamesCherrill
0
372
Member Avatar for moaz.amin.37

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?

Member Avatar for JamesCherrill
0
233
Member Avatar for Shawn_5

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);

Member Avatar for cool_zephyr
0
150
Member Avatar for My_1

You could store your button references in a 10x10 array (or a 100 element array) as you create them.

Member Avatar for JamesCherrill
0
328
Member Avatar for infiniteloop56

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)

Member Avatar for JamesCherrill
0
5K
Member Avatar for Renuka_1

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 …

Member Avatar for stultuske
-1
163
Member Avatar for steph7

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.

Member Avatar for JamesCherrill
1
1K
Member Avatar for My_1

Java bytes are unsigned 8 bit integers in the range 0-255 You can't use negative numbers with byte values.

Member Avatar for JamesCherrill
0
76
Member Avatar for nataraja833

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.

Member Avatar for Taywin
0
350
Member Avatar for mwenyenia07

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 …

Member Avatar for JamesCherrill
0
182
Member Avatar for divinity02

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 …

Member Avatar for JamesCherrill
0
153

The End.