aspose file tools*
The moose likes Beginning Java and the fly likes Help with an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with an array" Watch "Help with an array" New topic
Author

Help with an array

eric elysia
Ranch Hand

Joined: Mar 06, 2005
Posts: 70
Hello,

I am working on an array program. I have some array based questions.

How can I limit the user input to 80? When I run the program it allows me to enter in as many as I want.

Is there a way to know if the user has input symbols instead of letters or numbers?

I am going to break this program up into methods. One method that I will be using is: public static boolean palindrome(char[] a, int used)

Any suggestions are appreciated.
Thanks,
Eric

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Do you want to do something when the user reaches 80 or do you just want to chop off any characters that are entered after that?

What kind of symbols did you have in mind? A '?', a '$', a '*', a '-' or anything other than a letter, number or whitespace??


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
eric elysia
Ranch Hand

Joined: Mar 06, 2005
Posts: 70
I just want to be able to make sure the user did not enter more than 80 characters (including the period).

I meant these symbols: @, #, $, etc.

I guess I also need to convert the input to uppercase.

Thank you,
Eric
eric elysia
Ranch Hand

Joined: Mar 06, 2005
Posts: 70
OK, I have started to clean it up a little bit. Here is what I now have. I am not sure how to use the method:

public static boolean palindrome(char[]a, int used)

to keep track of how much of the array is used.

Any help is appreciated!
Thanks,
Eric

David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
You had the solution in your original post:What do you want your program to do if the user enters more than 80 characters: let them try again or exit?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with an array