Chas Martin

Greenhorn
+ Follow
since Oct 07, 2008
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
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chas Martin

Hey guys, thanks for the help. Here is my final and working project:
First is my main.java class:


Here is my secondary class called BinaryNodes.java:


Thanks for the help, I couldnt have done it without you guys!!
--Chas
13 years ago
Thanks for the help but I still cannot figure it out. I have tried everything I can possibly think of.
It still just keeps printing out every other comparison.
Im not sure and I cant find any info that tells me what the sc.next method does when there are no more tokens.
I have hit a wall and am so confused!
Can you give me a few more hints?
Thanks guys
13 years ago
I have this so far but Its skipping every other line


When I run it I get this :


How do I make it hit every line. Thanks for the help guys, I am a complete beginner so I can't go to far without getting stuck.
Thanks,
--Chas
13 years ago
Hi all, I here for a little help again.
I have an assignment that requires me to take in a .txt file like this:


I am supposed to read this in and print out the in-order, pre-order and post order.
The thing I am stuck on is getting it to look at the strings and lexicographically compare two strings. There is a compare method but I cant figure out how to make it work. Once I get that done, I dont think I'll have any problem getting it to print out the finished product which should look like this:


Does anybody know how to use the compare method because I am stuck bad! any help will be very appreciated.
Thank you all so much
--Chas
13 years ago
Thanks again, I'm am so close. I got it to print out the numbers at the beginning of each row but I can't figure out how to print the numbers at the top of each column. This is my output so far:


also, How would I go about putting a blank line in between the two tables just so it looks a little nicer?
[ November 23, 2008: Message edited by: Chas Martin ]
13 years ago
Thanks CR, I really appreciate the help.
One last thing; How can I get it to print the numbers that I am multiplying as well. It is only printing out the products but it is not showing you what numbers made those products, Ive tried probably ten different things but I cant get anything close to working. Any ideas???
13 years ago
I looked at the stuff you gave me but I just cant get it to work right. could someone explain to me how I would set up the printf method for this case.
13 years ago
oops, where I typed in what i want it to give me the 4 should be above the column with 4, 8, 12 in it and so on.
13 years ago
Hey guys, Im having a problem and I was wondering if someone could help me through it. I am student teaching a 12th grade honors math class and I want to show the kids an example of some things you can do with java and math. I made a few simple examples of easy calculations but I want to show them that you can do some things a little more in depth. Im trying to make a multiplication table using a file and a scanner as well as using multi-dim arrays and I want it to print out nice and clean. Its been a couple years since I took a java class and Im a little rusty.
this is what I have so far:

What Im doing is reading in a simple text file that I made which consists of this:
1-3 4-6
2-4 3-9
I split the tokens at the dash and insert them into a matrix form to make the mult table.
so far I have got it to give me this:
run:
4 5 6
8 10 12
12 15 18
6 8 10 12 14 16 18
9 12 15 18 21 24 27
12 16 20 24 28 32 36
BUILD SUCCESSFUL (total time: 4 seconds)

I want it to give me this:


then another table just like the one above but with rows from 2-4 and columns 3-9.
I know I need to use the printf method I dont know how to use it with the multi-dimensional array.
anything will help
Thanks for the help guys
[ November 21, 2008: Message edited by: Campbell Ritchie ]
13 years ago
Hi folks, I am here again to see if you guys can help me with an assignment. I have came here for help before and you guys helped me immensely. I have this assignment:
A file containing information about fruits is structured as follows. <fruit>
<type> Apple </type>
<color> Green </color>
</fruit>
<fruit>
<color> Yellow </color>
<type> Banana </type>
</fruit>
The file consists of tags and data. An opening and closing tag pair, <tag> ... </tag>, define a particular data element. Each fruit has a type and a color. Notice that either may appear first within the <fruit> ... </fruit> tags. Your program should read a file called �fruit.txt� with the above structure.
The output of your program should be the number of each type of fruit, and the total pieces of fruit. For example, the output using the lines above is:
Number of type Apple: 1
Number of type Banana: 1
Total pieces of fruit: 2
Your program should be flexible enough to handle a file containing an indeterminate number of fruit descriptions. However, you may assume that there will be no more than 100 different types of fruit.


I am not asking anyone to do this for me, I know how this place works. I've been looking at the problem trying to figure out where to even start and I've hit a wall already. I was just wondering where I should start. I am awfully confused as to how to get it to read the file and then perform the operations required. What method should I use? Any hints will be great to get me rollin.
Thanks guys
This is where Im at so far ----->
13 years ago
It works!!! Thank you guys, I appreciate the help so much!!
13 years ago
Thanks, I have been using the variable name countryName the whole time. Here is what I have:


Everything seems to be ok except countryName in the printf line still has squiggles
13 years ago
How can I make sure that the variables are definitely assigned. I have tried everything that I can think of and still, I get nothing. I have it now so it is printing out the first value, the second value and the change but no country name appears. It doesnt even give me an error anymore, it just doesnt print out the country name before the numbers. Any advice??
13 years ago
Hey guys, Thanks for letting me know that Fred. I had no idea but it really is much easier that way. Ill be sure to do that from now on.

Back to my problem;
I have entered the line:
System.out.printf("%1$s : %2$.1f : %3$.1f : %4$.1f%% change%n", country, first, second, change);
and everytime I do it, the string country has the red squiggles under it. When I place the cursor over it, it says "variable country may not have been initialized"
What did I do?
13 years ago
PS,
This is what I have this so far:
[edit]Add code tags. CR[/edit]
[ October 10, 2008: Message edited by: Campbell Ritchie ]
13 years ago