Write a program that reads a string and tests whether it begins with an uppercase letter or not
Answers
Answered by
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");
}
}
}
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
Physics,
7 months ago
English,
7 months ago
Computer Science,
7 months ago
Science,
1 year ago
English,
1 year ago