File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes Grains again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Grains again" Watch "Grains again" New topic
Author

Grains again

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Any way to get my answer in regular numbers and not sciectific notation? Or is that part of the fun?
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Carol there is a class in the API that can work with very large Integer values. The aim is to use that class in your assignment.
Look and you will find, sorry if I tell you more I'll give away the solution
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I have found one that seems perfect, but I haven't been able to get past the constructor. I keep getting an incompatible type or constructor not found error when I try to compile, even though I am using code similar to the program that runs. There is a constructor that takes one parameter of type String, but when I try to pass in the number 2, it says that an integer can't be converted to byte[]. this is very frustrating, and I don't know which way to turn! Help!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I am bummin' here. I can't figure out how to use the information on constructor methods. How do I use the constructor that takes a String argument instead of the byte[]? I can't figure out what I'm doing wrong, and I have to stop and I know I'm not going to get any sleep, and I don't know where to look for an answer and this is very upsetting! I thought the compiler could tell which constructor to call by the argument passed in as a parameter. If I'm not passing in a byte array, why does the compiler think I am!!! AGHHHHHHHHHHH!
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Carol if its the one I think you are using , need to pass the value as a string eg ( "100" ).
If that does not work mail me your attempt so I can see which class you do use.
Remember I'm at GMT +1. I suggest you send to both, I might have started my weekend here when you wake up, to start you friday
By the way, I saw your post somewhere that you cant find Just Java in you local library. My experience is that you dont really need the book to do the Assignments. I suggest, that if your budget is tight, download the Java Tutorial from Sun and Bruce Eckels Book (www.bruceeckel.com)
[This message has been edited by Johannes de Jong (edited May 17, 2001).]
[This message has been edited by Johannes de Jong (edited October 23, 2001).]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
To change the number 2 to a String, put it in quote marks "2".


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Duhhhhhhhh! I was using single quotes or no quotes. What an idiot! Thanks.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
o.k. I now have a clumsy beginning, but I can't check the first few lines of output because I don't know enough DOS commands to make my output print slower, or scroll back to check the first few lines to make sure my formatting is correct. Can anyone tell me how to do that? I can only see from square 43 on, so I don't know if the first lines are lined up properly. Thanks.
Richard Boren
Ranch Hand

Joined: Mar 01, 2001
Posts: 233
c:\my_java>java Grains >> output.txt
The >> will create the file output.txt and direct the output to it. You can then open the file in NotePade, WordPad, etc.
Also if you are using Windows NT or 98 you can right click on the title bar of the DOS window. This will give you menu with properties as one of the items. From properties you can change the size of the window. Depending on whether you're using NT or 98 some of the sizes will give you a scroll bar. I know NT will, but I'm not sure about 98.
Hope this helps.
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
You can also append any DOS command with "|more" and the output would pause when it filled the console...

Ciao!

------------------
I'm a soldier in the NetScape Wars...
Joel
[This message has been edited by Joel Cochran (edited May 11, 2001).]


Wait a minute, I'm trying to think of something clever to say...<p>Joel
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1749
    
    2
There's a Java solution too:

Your Grains program can stay as it is. Just invoke this wrapper program:
prompt>java LogGrains
I'm sure there's some way to write a more generalized redirector. I'm thinking of something along the lines of typing in
prompt>java Log Hundred Gertrude
where you could pass your class name in as a command-line argument. Could reflection help with this? (Don't know much about reflection.) I guess too the program would have to strip the first argument before passing the array along.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Thanks for responding so quickly everybody. Now I will get some sleep tonight!
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Carol a simple way to check your formating, try your loop with less than 64 say 10 or so
Thanks for the bit of code Michael
[This message has been edited by Johannes de Jong (edited May 12, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Grains again