Computer Science, asked by Manopk, 1 year ago

Write a program that reads a string and tests whether it begins with an uppercase letter or not

Answers

Answered by QGP
8
import java.util.Scanner;
public class Brainly_Java
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        System.out.print("Enter the string: ");
        String str = sc.nextLine();        //Taking String Input
        
        char ch = str.charAt(0);        //Extracting first character of String str
        
        if(Character.isUpperCase(ch))   //Checking if ch is an Uppercase character
        {
            System.out.println("String starts with an uppercase character");
        }
        else
        {
            System.out.println("String does not start with an uppercase character");
        }
        
        
    }
}
Similar questions