|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Java basic program guidance
Having some problems taking in the Java at Uni,
Was wondering if anyone could shine some light on it for me. My task is to write a program that will ask you to enter 2 words. the program will then print out both words on one line. However the words will be seperated by dots that will make the total length of the line 40. so if your first word was turtle and the second was abc, the output would be turtle...............................abc The program should check for certain conditions: 1. a word can not be longer than 37 characters; 2. there must always be atlest 2 dots in a line. The program should ask for the first word till a word of acceptable length is entered. it then does the same for the second word. once both words are input the prgram will either output an error message if the words are to long when combined; or output the required line with words. I have to write the program using while and/or do-while loops It also says something about the length of a string can be found out using myString.length(). I can understand the basic of what I need to do but with regards to word length and adding the required number of dots im fooked. Any pointers would be appreciated. Cheers. Quote:
Last edited by Nemi : November 17th, 2005 at 10:46 AM. Reason: Added comment |
|
#2
|
||||
|
||||
|
Quote:
How would you do this if you didn't have a computer? If you can explain it to me step by step in detail, translating it to Java should be a breeze...
__________________
Yawmark class Sig{public static void main(String...args){\u0066or(int \u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray() )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>> +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}} |
|
#3
|
||||
|
||||
|
How much programming do you understand.
Loops Calling Methods Arrays Doesn't really matter what language as long as you understand those concepts although it would help if you were familiar with them in java.
__________________
The day I get my hands on the cookbook it's all over. -nicky |
|
#4
|
|||
|
|||
|
I understand loops but very basic.
I am not here for someone to do the thing for me I am just asking for pointers on how to work out the length of a string. |
|
#5
|
||||
|
||||
|
Code:
String.length() Example: It's an extremely important skill to learn to read the API and become familiar with the tools you will use to program Java. Java has an extensive set of documentation that you can even download for your convenience. These "javadocs" are indexed and categorized so you can quickly look up any class or method. Take the time to consult this resource whenever you have a question - you'll find they typically contain very detailed descriptions and possibly some code examples. Java™ API Specifications Java™ 1.5 JDK Javadocs |
|
#6
|
|||
|
|||
|
Much appreciated just what I needed.
|
|
#7
|
||||
|
||||
|
Quote:
One thing that really drove home the point for me recently was a book containing a series of old Scientific American articles. One article was about a fictional tribe called the "Apraphulians" (April fools) that built a series of logical gates from ropes, boxes, and pulleys. Another was about some MIT students who built a computer that plays tic-tac-toe out of Tinkertoys. Not only were the articles fascinating, but they reveal the importance of thinking about the problem domain first and foremost. The computer (and the language used to communicate with it) is just another tool; what really matters is the algorithm... |
|
#8
|
||||
|
||||
|
I so wish more people understood that necessity in programing. I had the benefit of a teacher who cared enough about our proper education in programming that he didn't let us touch a computer or teach us a scrap of any programming language until he taught us how algorithms work. I swear we spent less than half the semester in the lab but when we finished that course we were better coders than most of the CS majors at my university. (This was in high school.) I've tutored programming students for years and only a few have ever been able to grasp that the algorithm is the solution not the syntax.
|
|
#9
|
|||
|
|||
|
I still get weird looks when i raid the recycling bins for scrap paper at work.
![]() |
|
#10
|
||||
|
||||
|
Quote:
I also wish people would grasp the concept of only optimizing when it becomes necessary. How frequently do we see code that is terribly convoluted in the quest for a 1% improvement in speed, when in fact the code in question is only accessed occasionally? This goes back to the statement that it's best to understand the algorithm ahead of time. It's much easier to write clean, clear, correct code if the necessary steps for accomplishing a task are understood ahead of time.
__________________
A -> B: Ride. The road to enlightenment is more fun on two wheels. The recent fuel price increase has had an interesting side effect. Many of the people that used to always say to me "You shouldn't ride a motorcycle, they're dangerous" are now saying "So, what kind of mileage do you get?"... |
|
#11
|
||||
|
||||
|
I used to tutor discrete math too. Big O is a bitch to learn but once you do it's your best friend.
|