File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Check incoming String for 10 digit number and making sure each digit is a numeral 0-9 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Check incoming String for 10 digit number and making sure each digit is a numeral 0-9" Watch "Check incoming String for 10 digit number and making sure each digit is a numeral 0-9" New topic
Author

Check incoming String for 10 digit number and making sure each digit is a numeral 0-9

Kofi Nimako
Greenhorn

Joined: Jul 19, 2004
Posts: 6
Hi All:
I am developing a telephone class and I have all set up as follows:


class Telephone
{

String telephoneNumber;
String name;
double amountOwed ;

public Telephone()
{
telephoneNumber ="";
name ="";
amountOwed = 0.0;
}

public Telephone(String s,String inName,double inAmountOwed)
{
setTelephone(s );
setName ( inName );
setAmountOwed ( inAmountOwed );
}

public String getTelephone()
{
return telephoneNumber;
}

public String getName()
{
return name;
}

public double getAmountOwed()
{

return amountOwed;
}

/**
* A setTelephone Method
*/
public void setTelephone( String s )
{

telephoneNumber = s.substring(0,10);
}

Please How do I complete the setTelephone( String s ) method above that will check the incoming telephone number to make sure that it has ten digits and that every digit is numeral between 0 and 9.?

Thanks


:roll:
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

What does this have to do with Servlets? Moving to Java In General (Intermediate)


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Check incoming String for 10 digit number and making sure each digit is a numeral 0-9