Write a program to input a string and then display it in Upper Case and also print the frequency of any character from the string. import java.io.*; import java.util.*; class StrCount
{
public static void main(String args[])throws IOException
{
Scanner in=new Scanner(System.in);
System.out.println("Enter a string:");
String n=in.nextLine();
String n1=n.toUpperCase();
System.out.println("The string in upper case:");
System.out.println(n1);
char ch='T'; int k=0;
System.out.println("Charachter to be searched for is T."); for(int i=0;i=1)
System.out.print("Character "+ch+" occurs "+k+" times.");
else
System.out.println("Character doesn't occur in this String..");
}
}
Output:
Enter a string:
Aman Himanshu …show more content…
Program 2:
Write a program to read the name of 5 students through keyboard and store them in a file “name.txt”.
import java.io.*; class WriteFile
{
public static void main(String args[])throws …show more content…
SUPER
SENIORS....
Program 8:
Write a program to input a string and separate words in it using String Tokenizer class. import java.io.*; import java.util.*;
class CountSpace { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int i=0; System.out.println("Input a String:"); StringTokenizer st=new StringTokenizer(br.readLine()); i=st.countTokens(); for(int