I have to write code that outputs the number of upper, lowercase digits and punctuation in a string but am having trouble with the asciival command.this is what I have so far but I recieve an error message about the use of my asciival command.an

InputBox input;
input= new InputBox();
input.setPrompt("enter an binary number");
String stringa;
int length;
length=0;
stringa= input.readString();
System.out.print("The total number of Charectures Is:");
System.out.print(stringa.length());
char letter;
int upper;
upper=0;
int increment;
increment=0;
letter=stringa.charAt(increment);
if (asciival(letter)>=65&&asciival(letter)<=90)
upper++;
increment++;

asciival();

Something like this?

public class Test 
{
    public static void main (String[] args)
    {
        String str = "HellO THIS is @#@%@ a M*#ED string";
        int length = str.length();
        int upperCount = 0;
        int lowerCount = 0;
        int punctCount = 0;
        int digitCount = 0;
        int whiteSpaceCount = 0;

        char ch = ' ';

        for(int i = 0; i < length; ++i)
        {
            ch = str.charAt(i);
            if(Character.isUpperCase(ch) == true)
                ++upperCount;
            else if(Character.isLowerCase(ch) == true)
                ++lowerCount;
            else if(Character.isDigit(ch) == true)
                ++digitCount;
            else if(Character.isWhitespace(ch) == true)
                ++whiteSpaceCount;
            else
                ++punctCount;
        }
        System.out.println("\nUppercase: " + upperCount + 
                            "\nLowercase: " + lowerCount +
                            "\nDigits: " + digitCount +
                            "\nWhitespaces: " + whiteSpaceCount +
                            "\nPunctuation: " + punctCount);
    }
}

Uppercase: 9
Lowercase: 12
Digits: 0
Whitespaces: 6
Punctuation: 7

This article has been dead for over six months. Start a new discussion instead.