• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with an array

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic