Kathleen Tillman

Greenhorn
+ Follow
since May 09, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Kathleen Tillman

Ok, I added the Guesses = 0 and the Guesses++ to my program. The problem I'm having (at least I think) is I can't figure out where to put the JLabel so that the integer "Guesses" will actually move up. Right now, it just shows Number of Guesses = 0 when I run the program and the number never changes. Here's what I have.
Constructor portion:


Program portion:


Any help given would be appreciated! Thanks!
Kat
8 years ago
Thank you all for your help!

I finally got the program working meaning that it actually recognizes the different numbers.

I have only one more problem and I'm hoping someone can lead me in the right direction:
I need to post how many guesses the person has attempted and I'm kind of at a loss as to how to do that.

Any insight would be great, thanks!

Kat
8 years ago
Ok, so I changed the guess problems. Thanks for the help on that!!
The problem I seem to be having though is that the program won't recognize that I've put a different number in. (i.e. I'll put the number 45 in and the program will say "Too High", so I'll put the number 33 in and it'll again say "Too High", all the way down to number 1, which will again say "Too High". Obviously my program is not working correctly somewhere, but I cannot for the life of me figure out where.

Also, I'm not quite sure I understand what you mean with the button



What would that be used for and where?

Thanks,
Kat
8 years ago
Ok, so here's the issue. I can compile and run it fine, but when I load the game, it will only take one guess and will let me go no further. In other words, it asks for my guess and I enter say "45", and it says "Too high." Well, I enter another number, but then it won't go anywhere. Can you look at the code below and help me? Also, if anyone could give me any hints as to how to show the number of guesses a user has made so far, it would be greatly appreciated. Thanks!
I was wrong, it will let me move, but the number is constantly "Too High" and won't change. Any help would be appreciated.


Add the section that makes the program run...

8 years ago
Thank you so much! That took care of the line problem.

Is there any possible way someone can also help me with the swaps and passes portion of the problem? Like I said, I have portions showing up, but I'm not sure if they are correct.

Thank you so much!

Kat
8 years ago
Thanks all for your help. I'm hoping that I'm doing this right by posting a continuing question for the same problem.
I've worked on this code all weekend to try to get it to work and I think I got most of it correct. The problem I'm having is I don't think I'm getting the passes working correctly and I'm not sure about the swaps either, though I finally am making it work as showing an answer.
The other problem I'm having is that I can't seem to get everything to print on separate lines. Can you please look at my code below and see if you see anything wrong?



This is my output...


Before sorting, the list elements are:
23 17 5 90 12 44 38 84 77 Total number of Swaps: 12
Total number of Passes: 12
After sorting, the list elements are:
5 12 17 23 38 44 77 84 90
----jGRASP: operation complete



Any help anybody could give me would be greatly appreciated.

Kat
8 years ago
Ok, I got that. Thank you. It was just a matter of moving that bracket up. One more question on this. I cannot seem to make the next line print separately. Right now the code looks like this:



and the return when I run looks like this


Before sorting, the list elements are:
23 17 5 90 12 44 38 84 77 After sorting, the list elements are:
5 12 17 23 38 44 77 84 90
----jGRASP: operation complete.



Why is it not separating the line of numbers and the "after sorting, the list elements are:"

Sorry, to ask so many questions.

Also, can you lead me to a website or somewhere that can help me when it comes to inserting a counter to count swaps and passes?

Thanks so much, Kat
8 years ago
Sure. No problem. I'm trying to post everything, right, sorry.

Here's the code. I'm not sure where the mistake is.
8 years ago
I tried that.

I copied



All I added was to change System.out.print to System.out.println instead to separate and I got this:


----jGRASP exec: java Program7
Before sorting, the list elements are:
23
After sorting, the list elements are:
5 12 17 23 38 44 77 84 90



I'm not at all sure why none of this isn't working.

8 years ago
Hi All -

I'm having a bit of a problem: My assignment is to enter an array of numbers and then sort them using bubble sort. I have got the bubble sort working(finally), but I also have to do four things: show the unsorted array before sort, show the unsorted array after it has been sorted; show how many passes; and show how many swaps. Right now, I've only gotten so far as sorting, I haven't even touched the counter yet, which is not what I'm asking about (yet) because I haven't worked on it. What I am asking about, though, is help with the problem I'm currently having. I have gotten the sorted array to print, but I can't seem to get the array to print before the sort. My code is below. Does anybody have any idea how to get the program to show the array before it's sorted?


It compiles correctly somehow, but when I run it this is what I get:


Before sorting, the list elements are:
[I@66848c
After sorting, the list elements are:
5 12 17 23 38 44 77 84 90


Any help I could get would be appreciated.

Thanks,
Kat
8 years ago
Thank you so much for your help. The last time I moved it up a line, I forgot to press "-1" to exit, so I thought it wasn't working.

Thanks!!
8 years ago
Hi all,
I'm having a problem with my java program. I am trying to make a program where the user enters a product number and a quantity, then at the end of the program the total of the order pops up. I have gotten as far as the last statement on my code without compilation errors, but when I try to display the total it either won't show up (if I move it up a bracket) or I get a compilation error. Can someone possibly help me with this? Thanks!



The error I get is this:

----jGRASP exec: javac -g C:\jGRASP Projects\JavaLoopsandSwitchStatements.java

JavaLoopsandSwitchStatements.java:65: <identifier> expected
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:65: illegal start of type
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:65: illegal start of type
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:65: ')' expected
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:65: ';' expected
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:65: illegal start of type
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:65: <identifier> expected
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:65: ';' expected
JOptionPane.showMessageDialog(null, "The total is: " + orderAmount);
^
JavaLoopsandSwitchStatements.java:66: reached end of file while parsing
}
(I apologize if I didn't format the errors correctly.)

Thanks, Kat
8 years ago