Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with an array

 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic