Write a program to input 50 names in an array and print all name beginning with letter b. in java programming language
Answers
Answered by
2
- Write a program to input 50 names in an array and print all name beginning with letter b.
The given code is written in Java language.
import java.util.*;
class StringProgram
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter 50 Strings in array..");
String s[]=new String[50];
for(int i=0;i<50;i++)
{
System.out.print("Enter: ");
s[i]=sc.nextInt();
}
for(int i=0;i<50;i++)
{
String str=s[i].toLowerCase();
char ch=str.charAt(0);
if(ch=='b')
System.out.println(s[i]);
}
}// end of main()
}// end of class..
Similar questions
History,
4 months ago
Science,
4 months ago
English,
4 months ago
Science,
8 months ago
Political Science,
8 months ago
Computer Science,
11 months ago
Math,
11 months ago