1
   

java

 
 
Reply Wed 17 Sep, 2003 04:11 pm
can you teach me how to write a java program a very simple one to produce a palindrome from a given input string using cocatenations with one or more methods of a word class? how would you write a word class and and test class to instantiate word object from the input string? can you show me how to output it to an output stream using the system.out.println? is this the method of printing it out? are there any online tutorials about this? would you mind teaching me??
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 1 • Views: 1,000 • Replies: 8
No top replies

 
yeahman
 
  1  
Reply Wed 17 Sep, 2003 06:49 pm
"palindrome from a given input string using cocatenations with one or more methods of a word class"

what do you mean by that?
what does this "test class" do?
and where is the input coming from?

output is System.out.println(). the S is capitalized. i've spent many nights trying to figure out why programs didn't work only to find that the S wasn't capitalized.

i'm sure there are plenty of tutorials out there. search google. for usage of specific methods consult the sun java api.
0 Replies
 
USAFHokie
 
  1  
Reply Thu 18 Sep, 2003 04:23 pm
gee, this sounds a LOT like a freshman computer science major... you can look up the "word class" on your own... but this is how you're gonna do it: create two instances of a word class, inputWord and PalWord. but will start out as empty strings. read your input string into the inputWord variable. you should be able to access each element of the variable (each character of the string) using an access operator with a numerical index. ex: if the input word is "computer", then the value returned by inputWord[2] would be the character 'm'. however the access method may look like inputWord.get(2) or inputWord.at(2). so you'll have to read the document files on the word class. so anyway, make a loop that starts with the last element in the input string and appends it to the palidrome string. something like :

for(int counter = length of inputWord; while counter is greater than 0; subtract 1 from counter){

palWord = palWord + inputWord.get(counter);

}//end for loop

that was written in C++ syntax... but it should be nearly identical to what you need.... that's the basics, hope it helps.
0 Replies
 
ebrown p
 
  1  
Reply Sat 11 Oct, 2003 02:02 pm
Here is a link to a program that (believe it or not) does exactly this. It is written in C and is quite possible the most beautiful piece of code ever written -- so good, in fact, it won a contest.

Go ahead, check it out, you won't be disappointed.

http://www.acme.com/software/c.otto.c/

(No really, all of you should look at this!)
0 Replies
 
Monger
 
  1  
Reply Sat 11 Oct, 2003 02:08 pm
ebrown, I'm not a C programmer so no doubt I'm not fully appreciating the genious of that code, but still...damn that's cool.
0 Replies
 
Heliotrope
 
  1  
Reply Wed 15 Oct, 2003 02:54 am
No no no, the most beautiful piece of code ever written was in 6502 binary machine code that took advantage of a regular glitch in the clock signal to squeeze one more instruction out of the processor every 20 cycles.

*breathes on fingernals and buffs them on my Tool t-shirt.*

Wink
0 Replies
 
jpowell
 
  1  
Reply Wed 15 Oct, 2003 04:15 am
Heliotrope wrote:
No no no, the most beautiful piece of code ever written was


...BitTorrent. Written in Python. Go Python.

I just dig Python becuase I use it to write mathmatical tutoring program for my 8 your old neph. Python is simple and powerful. And BitTorrent kicks ass.
0 Replies
 
ebrown p
 
  1  
Reply Wed 15 Oct, 2003 05:57 am
This might be appropriate here, at least it is a good read. Every programmer should certainly know this story -- The Legend of Mel

http://www.farid-hajji.net/fun/cj-progmachine.html
0 Replies
 
Heliotrope
 
  1  
Reply Wed 15 Oct, 2003 02:10 pm
jpowell wrote:
Written in Python.


I've not heard of this one. Mind you though I'm 20 years out of date when it comes to programming.
I did all my stuff on BBC Micros, Commodore 64s and ZX Spectrums with 6502A and Z80A 8 bit processors.
Shocked
0 Replies
 
 

Related Topics

Clone of Micosoft Office - Question by Advocate
Do You Turn Off Your Computer at Night? - Discussion by Phoenix32890
The "Death" of the Computer Mouse - Discussion by Phoenix32890
Windows 10... - Discussion by Region Philbis
Surface Pro 3: What do you think? - Question by neologist
Windows 8 tips thread - Discussion by Wilso
GOOGLE CHROME - Question by Setanta
.Net and Firefox... - Discussion by gungasnake
Hacking a computer and remote access - Discussion by trying2learn
 
  1. Forums
  2. » java
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.47 seconds on 04/25/2024 at 03:37:26