This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Absolutely, we're here to help. We don't like to hand out code, though -- we like to help you figure it out for yourself. So my first question to you is, what do you have so far? If it's nothing, then what are your thoughts about what to do first?
First one is just to read line, break it into words, and put each word in array. Than just check each word weather its first letter belongs to a set of Capital letters. I had text how to compare sets somewhere so I would still need to separate words and create dynamic array or something like that (because number of words in line is unknown)
Another idea is to create cycle that scans one letter and if it's capital than prints it and keeps on scanning and printing symbol by symbol until it reaches space. After that again, scans one letter and checks weather it's capital or not and so on... I prefer this solution and have an idea how to write a cycle but have no idea how to scan one character in java if it's possible at all...
Ryan Beckett
Ranch Hand
Joined: Feb 22, 2009
Posts: 192
posted
0
Get the ascii values of the characters and check them against the ascii table.
Ernest Friedman-Hill
author and iconoclast
Marshal
Ryan Beckett wrote:Get the ascii values of the characters and check them against the ascii table.
No, please don't do this! First of all, Java doesn't use ASCII, but Unicode; your "capital letters" could be in many different alphabets around the world, not just ASCII. Secondly, the Java libraries provide methods to do these kinds of tests correctly for Unicode. Look at the static method isUpperCase in the java.lang.Character class.
Arthur Donting
Greenhorn
Joined: Mar 22, 2009
Posts: 10
posted
0
Guys, I might have something here...
It works for me perfectly.
what do you think?
Ryan Beckett
Ranch Hand
Joined: Feb 22, 2009
Posts: 192
posted
0
Never thought about that, and to think they teach us that in college. Thanks.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
4
posted
0
You may find a Scanner easier to use than BufferedReader, assuming the file is a text file.
You may find the split method of the java.lang.String class useful, too.
Moojid Hamid
Ranch Hand
Joined: Mar 07, 2009
Posts: 120
posted
0
Arthur do you know what "regular expressions" are? If you don't have a look at: