Results 1 to 18 of 18
- 11-24-2008, 04:26 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
Need Help With VERY Simple Program -- Newbie!!!
Hey all,
I am not a Java programmer and as part of a job application I'm being asked to do a simple (not!) Java program. Can anyone help me with the following exercise? Thanks!
You are to create a console application that accepts exactly one command-line argument. If it doesn’t receive the argument, the application must display an error message and exit. The application must parse the text input and output the number of times each letter of the alphabet occurs in the text. Case sensitivity is not required.
For example, if the command-line argument is “baaad” the displayed result must be:
There are 3 A's
There are 1 B's
There are 0 C's
There are 1 D's
There are 0 E's
There are 0 F's
etc...
- 11-24-2008, 04:43 PM #2
hhhmmm... probably not
I do appriciate your honesty... but nobody here is going to give you code so you can pass it off as your own and get a job where you need java programming skills that you don't have. If you want to post your code and ask questions about doubts/problems, then there is plenty of help to be given.
With that said, some suggestions:
- Here's the sun tutorials (should but easy if you have other programming languaje experience):
The Java™ Tutorials - Here's the Java SE 6 API Specification
Java Platform SE 6
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- Here's the sun tutorials (should but easy if you have other programming languaje experience):
- 11-24-2008, 04:45 PM #3
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 12
somethingfast, study loops. Besides that... if you can't do this, why even bother applying for a programming job?
I die a little on the inside...
Every time I get shot.
- 11-24-2008, 04:46 PM #4
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
Actually, the job is not for Java. It's for a .NET training program but you have to demonstrate programming skills in narrow range of options (Java, VB, and C++), none of which I have. My background is in SQL/Access/SAP. I REALLY need this training which translates into a job. I totally understand your position and am only asking because I'm desperate and I know that I won't actually be programming in Java. I would be eternally grateful for help :o
- 11-24-2008, 05:02 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 25
At least, did you put some effort on this. CJSLMAN give a link for the tutorial. Go to that tutorial and search on the loops, first of all. And try to find number of each characters in a string as you said. Just forget all command lines arguments.
Try something first of all lol. :)
- 11-24-2008, 05:05 PM #6
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
I'll give it a shot. Thanks guys. The tutorial didn't have a "loops" section that I could find. This should be like 20 lines of code max, right?
- 11-24-2008, 06:32 PM #7
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
One more question as I begin to tackle this. I assume by loop you mean an if-then or for statement is involved? And what is the mechanism by which the characters in the word entered are counted and converted to integer values for output? I REALLY appreciate your tips/help!
- 11-24-2008, 07:08 PM #8
I'm going to tell you what you need to use to do this but you have to figure out how to get it work.
The String api contains a charAt() method(or possibly toCharArray() ) ;
use a for loop to iterate through your word.
an int counter variable for each letter.
Now that you've been given that write up some code and post it if you get stuck.
P.S. ya your looking at about 20 lines. The loop logic will be the majority of your code.
- 11-24-2008, 07:10 PM #9
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
^ you rock! thanks, i will put together something with spit and duct tape and post back here lol
- 11-24-2008, 10:28 PM #10
Tutorial loop section
It's in the "Control Flow" section of the tutorials:
Control Flow Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
Here you can find the if-else, while loop, for loop, etc
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 11-25-2008, 02:02 AM #11
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
I appreciate all the help, folks. Can you tell me if I'm on the right track with this start to get the word and determine length of word? Thanks...
public class CountWordLetters {
public static void main(String[] args) {
String InputWord = JOptionPane.showInputDialog("Please enter a string: ");
int len = InputWord.length();
char[] tempCharArray = new char[len];
char[] charArray = new char[len];
for (int i = 0; i < len; i++) {
tempCharArray[i] = InputWord.charAt(i);
}
- 11-25-2008, 03:25 AM #12
Is it working?
- Does it compile?
- If yes, does it run?
- If yes, does it produce the expected output ?
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 11-25-2008, 03:38 AM #13
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
I don't have any ability to compile unless there is something on the average Windows desktop that I'm unaware of.
- 11-25-2008, 05:26 AM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 25
- 11-25-2008, 06:31 AM #15
Member
- Join Date
- Nov 2008
- Posts
- 8
- Rep Power
- 0
yeah, just notepad
-
Either go to the Java download page and download the JDK or give up. Simple as that.
- 11-25-2008, 07:36 AM #17
Amazing...
I really don't believe it ...
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 11-25-2008, 08:38 AM #18
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 25
Similar Threads
-
Stuck - simple program
By dirtycash in forum New To JavaReplies: 4Last Post: 11-24-2008, 08:44 PM -
Not able to debug simple hello world program
By amit123solanki in forum New To JavaReplies: 1Last Post: 06-12-2008, 04:41 PM -
Simple newbie problem: import 3rd party jar
By jodyflorian in forum EclipseReplies: 5Last Post: 05-30-2008, 05:02 AM -
help with simple program in java
By katie in forum New To JavaReplies: 2Last Post: 08-06-2007, 09:03 PM -
help with simple java program
By leonard in forum New To JavaReplies: 3Last Post: 07-30-2007, 10:40 AM
Bookmarks