Hello, all. I'd greatly appreciate some assistance in getting this program working properly. Thank you!

Here is my attempt so far. It's is not working like the instructions above ask.

import java.util.Scanner;
public class MixedCase 
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
       String a;
       Scanner input = new Scanner (System.in);
       System.out.print("Please enter a string: ");
       a = input.nextLine();

       for (char i = 0; i < a.length(); i++)
        {            
            if ((Character.isUpperCase(a.charAt(i))) && Character.isLowerCase(a.charAt(i)))
        {
                    System.out.print("This string has both lower and upper case characters.");
        }
            else
                {
                    System.out.print("This string does not have both lower and upper case characters.");
                }
        }
    }
}
Member Avatar for gowans07

you have declared i as a char, you need to declare it as an int. that sould fix your problem

Why do you think that? Java char is a numeric 16 bit integer type, perfectly OK, and converted to int by Java whenever needed. Did you test that before posting? It may be an odd choice, but its not wrong.
It certainly won't fix his (unspecified) problem, which is caused by the logic being way off - eg the boolean expression on line 17 will alwyas return false, which presumably is not what he intended.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.