wood burning stoves 2.0*
The moose likes Cattle Drive and the fly likes java 1b hundred ugh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "java 1b hundred ugh" Watch "java 1b hundred ugh" New topic
Author

java 1b hundred ugh

Harry Graham
Greenhorn

Joined: Feb 18, 2009
Posts: 10
lol I am banging my head against the wall and stubbing my toes on the coffee table and for the life of me just can't figure out how 1b is just about math. I want to try to use arrays but that is not in the assignment. Someone kick me.

I have figured out how to get the int value of "Gertrude " but now how do I / that into the console length that I declare.

console/"Gertrude "?

BTW I know the answer is staring at me just don't see it.

Hope I am not the only fool
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Hi Harry. What are you talking about ? Are you talking about an assignment ? The cattledrive ?


[My Blog]
All roads lead to JavaRanch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Yes, it is the cattle drive, so I shall move this thread to that forum. What you are supposed to do is print
Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry
Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry
Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry
Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry
Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry
Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry
Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry
Harry Harry Harry Harry Harry Harry Harry Harry Harry
Now "Harry " contains 6 characters, [H=1 a=2 r=3 r=4 y=5 space =6]. So you have to work out how many "Harry "s you can get into the 80 character width of the command window. That is where the arithmetic comes in.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Harry, are you sure that you have to work out how many times the name can be printed completely on each line? Or, rather, just write code that will print to the next line if the complete name doesn't fit?
Harry Graham
Greenhorn

Joined: Feb 18, 2009
Posts: 10
Thanks for moving thread, sorry about having it posted in wrong forum.
Not there yet but still playing. hmm
"IF" or "for" now that is the question

Stefan Brandenberger
Greenhorn

Joined: Aug 31, 2009
Posts: 12
Carol Murphy wrote:Harry, are you sure that you have to work out how many times the name can be printed completely on each line? Or, rather, just write code that will print to the next line if the complete name doesn't fit?


Well, the latter can be evaluated by computing the former, no?
Harry Graham
Greenhorn

Joined: Feb 18, 2009
Posts: 10
I can get 1 line to print out correctly or have the print out run forever, kind of funny actually, now to just tweek it a little more. Looking forward to the first nit pick with this.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Stefan Brandenberger wrote:
Carol Murphy wrote:Harry, are you sure that you have to work out how many times the name can be printed completely on each line? Or, rather, just write code that will print to the next line if the complete name doesn't fit?


Well, the latter can be evaluated by computing the former, no?


Yes, it can. But is that the best and only way to perform this task?
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Actually, Harry, I went back to look at my source for this assignment. The solution is very simple, and does not require anything as fancy as an array. It uses simple math. Don't complicate a simple solution.
Cryptic enough for you?
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Carol Murphy wrote:Harry, are you sure that you have to work out how many times the name can be printed completely on each line? Or, rather, just write code that will print to the next line if the complete name doesn't fit?


I have to correct myself here. I don't want to confuse you further. You do need to figure out how many times the name will fit on each line. I didn't phrase this well. What I should have said was that the solution to this is not complicated. A simple approach is the key.
My bad!
Harry Graham
Greenhorn

Joined: Feb 18, 2009
Posts: 10
If this needs deleting please delete...
Ok I am still fighting this project, I got it to run correctly now I am being told that I am calling a method 100x and will get same result each time, ok I understand that but how do I make it so that I only grab what I need? I have zero programming exp and my head hurts.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
What if you call the method once and save the result


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
margaret gillon
Ranch Hand

Joined: Nov 12, 2008
Posts: 317
    
    5

I have zero programming exp and my head hurts.


Harry since you have no programming experience you may want to get another book like Java for Dummies 4th edition by Barry Burd that includes more detail on basic programming concepts like loops. I have been programming for 25 years and I use both the course text Just Java2 and the Java for Dummies to help me with the Cattle Drive assignments. Java is very different than the traditional languages I use at work and Burd's detailed explanations help me. There are book reviews of other Java books on this forum Javaranch book review forum


I just checked on amazon.com and Burd has an introduction to programming book that uses Java, too. Beginning Programming with Java For Dummies (For Dummies (Computer/Tech)) (Paperback) . ISBN-10: 0764588745.
Harry Graham
Greenhorn

Joined: Feb 18, 2009
Posts: 10
Why do you change " int j = blahblah //This is what I am doing "
to " int ExplanationOfWhatIsBeingDone = blahblah "
Is it for when longer codes are written and you can not just go int a - z?
I thought the comment would make things simpler.
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1357
    
  17
There are good comments, bad comments, and awful comments.

Good comments explain why you did something the way you did it. It can be a gotcha, or a business rule, or a trade off for performance reasons.

Comments that state the obvious, are cryptic, imprecise, incomplete, outdated, etc are Bad(tm)

Comments that are misleading are awful.

The thing is, if you can make your code speak for yourself, then a lot of the time you won't need comments; less comments -- less to read -- less to bother your brain with.
Also if the code itself tells you what is going on, it is MUCH easier to read and understand, and then it is cheaper to maintain (because generally you read code more than you write it, and often you read it when you've been away from it long enough to have forgotten what it is about... or you never saw it before because someone else wrote it).
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
This very subject is one of the things I found most valuable about doing the drive. The simple act of naming variables in such a way that they describe their purpose makes a huge difference in readability, and thus my ability to comprehend the code I'm trying to decipher.
One example from Java books and also many practice certification exams is the use off foo and bar for variable names. I have a hell of a time with any code fragments that use foo and bar, because of what they stand for. I can't get past it. My mind goes.......foo bar. What can I say. So as petty as it may seem, the discipline of naming variables to help describe their function is a very good practice! And for those of us who hate typing, there's always copy and paste!
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1357
    
  17
When I was taking exams in programming in college, the programs were in Java, but the variables were in Norwegian. My mind shriveled and died a little trying to figure out what the program was supposed to be doing, and since the program was hard copy (exam was paper based, not on a computer) I couldn't just replace the variables with translations (which were provided on a separate sheet for me).
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Yikes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java 1b hundred ugh
 
Similar Threads
class 1
style guide
text formatting using java
Assignment 1b
A dumb question, i know.........