Computer Science, asked by harishankerverma286, 9 months ago

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 anindyaadhikari13
2

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Write a program to input 50 names in an array and print all name beginning with letter b.

\star\:\:\:\sf\large\underline\blue{Program:-}

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