Results 1 to 11 of 11
Thread: Need Help With Assignment
- 02-24-2011, 09:41 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Need Help With Assignment
I'm taking an introductory to java course. I have been completing assignments that are rather basic with if else statements, etc.
I need some help on where I'm supposed to start off here.
Here's the assignment
Write a Java program Search.java to prompt the user to enter an arbitrary string of characters. The program searches for digit characters, and extracts the characters that are digits, and also extracts the characters that are non digits, and provides a count of each.
- 02-24-2011, 10:18 PM #2
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Is this on a window or can you use java.util.Scanner ?
- 02-24-2011, 10:21 PM #3
When starting an assingment take baby steps.
Write a class and a main method that does nothing.
Make sure it compiles (fix errors).
Move on.
Get user input and print back to screen.
Make sure it compiles and runs.
Iterate over the user input and print one character at a time.
Make sure it compiles and runs.
Iterate over the user input and only print the numbers.
etc
- 02-24-2011, 10:21 PM #4
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
On a window
- 02-24-2011, 10:51 PM #5
Junky is correct. What have you done so far? Follow Junky's steps and let us know which one you got stuck on, what you have so far, and what errors you get.
- 02-24-2011, 11:16 PM #6
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
import javax.swing.*;
class Search
{
public static void main (String [] args)
{
String str;
str = JOptionPane.showInputDialog("Enter String");
int result = str.length();
JOptionPane.showMessageDialog(null,
"String" +result);
}
}
So Far I just need to figure out a way to seperate the characters entered into digits and non digits.
- 02-24-2011, 11:17 PM #7
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Example of How it is supposed to look like
User enters: hjjkk144
The message box is supposed to display the following:
3 Digits: 144
5 Characters: hjjkk
- 02-24-2011, 11:21 PM #8
Did you move onto the next step I suggested and loop over the String and print each character one at a time?
- 02-24-2011, 11:33 PM #9
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
- 02-24-2011, 11:39 PM #10
Senior Member
- Join Date
- Feb 2011
- Posts
- 118
- Rep Power
- 0
- 02-25-2011, 12:09 AM #11
Similar Threads
-
Need help with a HW assignment
By mackavelirip in forum New To JavaReplies: 4Last Post: 02-17-2011, 01:36 AM -
assignment help
By esallender in forum New To JavaReplies: 4Last Post: 10-25-2010, 12:10 PM -
GUI First Assignment-DUE 8/1/08
By ljk8950 in forum AWT / SwingReplies: 2Last Post: 08-01-2008, 04:23 AM -
First GUI Assignment
By ljk8950 in forum New To JavaReplies: 1Last Post: 07-31-2008, 07:29 AM
Bookmarks