frequency of a letter in a string

frequency of a letter in a string

Could someone answer in netbeans please

Write a program that takes in a string and a letter from the user and displays the number of appearances of the entered letter in the entered string.

View Answers

February 22, 2012 at 10:06 AM

import java.io.*;
import java.util.*;

class  CountCharacters {
  public static void main(String[] args) throws Exception{
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  System.out.print("Please enter string ");
  System.out.println();
  String str=br.readLine();
  String st=str.replaceAll(" ", "");

  char[]third =st.toCharArray();
  for(int counter =0;counter<third.length;counter++){
  char ch= third[counter];
  int count=0;
  for ( int i=0; i<third.length; i++){
  if (ch==third[i])
  count++;
}
boolean flag=false;
for(int j=counter-1;j>=0;j--){
if(ch==third[j])
flag=true;
}
if(!flag){
System.out.println("Character :"+ch+" occurs "+count+" times ");
}
}
}
}









Related Tutorials/Questions & Answers:
frequency of a letter in a string
frequency of a letter in a string  Could someone answer in netbeans please Write a program that takes in a string and a letter from the user and displays the number of appearances of the entered letter in the entered string
Java count frequency of words in the string
Java count frequency of words in the string. In this tutorial, you will learn how to count the occurrence of each word in the given string. String..., input validation, and file conversion. Here we are going to find the frequency
Advertisements
Count letters in a string.
Description: This tutorial demonstrate how to find number of letter exists in a string. The str.length() method find the length of string. Code...;public static void main(String[] args) {   
ModuleNotFoundError: No module named 'frequency_analyzer'
ModuleNotFoundError: No module named 'frequency_analyzer'  Hi, My... named 'frequency_analyzer' How to remove the ModuleNotFoundError: No module named 'frequency_analyzer' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ruword-frequency'
ModuleNotFoundError: No module named 'ruword-frequency'  Hi, My... named 'ruword-frequency' How to remove the ModuleNotFoundError: No module named 'ruword-frequency' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'frequency_analyzer'
ModuleNotFoundError: No module named 'frequency_analyzer'  Hi, My... named 'frequency_analyzer' How to remove the ModuleNotFoundError: No module named 'frequency_analyzer' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'frequency-controller'
ModuleNotFoundError: No module named 'frequency-controller'  Hi...: No module named 'frequency-controller' How to remove the ModuleNotFoundError: No module named 'frequency-controller' error? Thanks   Hi
ModuleNotFoundError: No module named 'letter'
ModuleNotFoundError: No module named 'letter'  Hi, My Python... 'letter' How to remove the ModuleNotFoundError: No module named 'letter'... to install padas library. You can install letter python with following command
ModuleNotFoundError: No module named 'letter'
ModuleNotFoundError: No module named 'letter'  Hi, My Python... 'letter' How to remove the ModuleNotFoundError: No module named 'letter'... to install padas library. You can install letter python with following command
letter counting for the smallest word
letter counting for the smallest word  How do I program my java... static void count(final String str){ Runnable readRun1 = new Runnable...); String st=str.replaceAll(" ", ""); char ch[]=st.toCharArray
how to delete a letter in a word?
how to delete a letter in a word?  how to delete a letter in a word? for example if i enter= roseindia, i want to delete 's', then output= roeindia
letter count problem - Java Beginners
letter count problem  i have a problem in my java coding to count two characters of a string. eg to count the letter "ou" in the string "How do... it here is my coding: public int countCharset(String s, String cc) { return
Automatic Capital letter
to make a automatic capital letter. I have a jTextfield1, if i type aaaaaa...); label=new JLabel("Enter String:"); p=new JPanel(); p.add(label); p.add(text...(KeyEvent e){ String st=text.getText(); text.setText
string
inputString = br.readLine(); FirstLetter letter=new FirstLetter(); String words...string  a java program to input a string and display the string...*; import java.io.*; public class FirstLetter{ public static String
Check for character is letter or not.
Description: This tutorial demonstrate the use of Character.isLetter() method which checks whether the value stored in char data-type variable is letter...;{   public static void main(String[] args) 
ModuleNotFoundError: No module named 'letter-list'
ModuleNotFoundError: No module named 'letter-list'  Hi, My Python... 'letter-list' How to remove the ModuleNotFoundError: No module named 'letter-list' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'phoenix-letter'
ModuleNotFoundError: No module named 'phoenix-letter'  Hi, My... named 'phoenix-letter' How to remove the ModuleNotFoundError: No module named 'phoenix-letter' error? Thanks   Hi, In your python
POI Word document (Letter Template)
POI Word document (Letter Template)  Dear Team, i need code for generating word document(letter format). i am unable to get the code for formats, font settings, letter type settings. please help me for the same. Thanks
How to delete line starting with a letter in java Regex?
How to delete line starting with a letter in java Regex?  Hi, i 'm... lines which starts with a letter like G or g in a text. i tried this but it's not working, please i need help. [CODE] String[] paras = Pattern.compile("(?i)((s
Check for character is letter or digit.
is a digit or letter using isLetterOrDigit() method. Code:ADS_TO_REPLACE_1...;public static void main(String[] args) {   
STRING.....
STRING.....  plzz sent me d code for counting vowels in a string... gui programme
string
string   difference detween "public static void main (String[] args) " and "public static void main (String args[])" in java but it executes both... "String args[]" can mean a "string array called args which is an array
string
string  String helloString = new String(helloArray); System.out.println(helloString); i am unable to understand this. could u plz explain
string
string  a java program using string function to input any string... ArrangeStringAlphabetically { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string
String
String  how to add spaces with string functions.?   Hi... { public static String addSpaceToRight(String s, int n) { return String.format("%1$-" + n + "s", s); } public static String addSpaceToLeft(String s, int n
String
characters in string?   import java.util.*; class RemoveDuplicateCharatcersFromString { public static String removeDuplicates(String s... < s.length(); i++) { String st = s.substring(i, i + 1
String
String  write down the code of remove any character from a given string without using any string function   please give me the code of remove any given character from a given string without using function
string
*; class ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String: "); String st=input.nextLine(); String str[]=st.split
string
string   just i want to a program in a short form to the given string in buffered reader for example input string: Suresh Chandra Gupta output: S. C...; public class StringTest { public static void main(String [] args
string
string  write a program to accept the string and store the reverse stream into another array and print
string
string  java prgm to find total occurence of a given string pattern in a sentence
string
string  java prgm to find total occurence of a given string pattern in a sentence
String
String  write a program using string it should replace 'c'char to integer number as 1 in whole source
String
String  How to Convert sunnapu gopal to Sunnapu Gopal in java using String
String
String  how to print in between numbers if the question "String s = "1,2,3,4,5,6,8,-25"" out must be 1 2,3,4,5,6,7,8,9,10,upto25
string
and also displaying that contain word? Like I want to find "a" in the string... and a character. It then count the occurrence of that character in the string and display... String_Example { public static void main(String[] args
string
string  program for String reverse and replace in c,c++,java e.g.Input:10,20,hello output:hello;20;10   Hi Friend, Try the following java...(String[] args) { String array[]=new String[5]; Scanner input
Welcome! to the News letter archive
News Letter Archive     ... letter sent our users.  ADS_TO_REPLACE_1 Newsletters are regularly... Letter Archive Date Subject
string
string  a java program using string function that computes your initials from your full name and display them   Please visit the following links: http://www.roseindia.net/tutorial/java/core/printInitials.html
string
string  a java program using string function and access modifiers to automate the insurance company which will have to manage the information about policy holders Data Members: 1)Policy No 2)Name of policy holder 3)Address 4
ModuleNotFoundError: No module named 'odoo9-addon-mail-as-letter'
ModuleNotFoundError: No module named 'odoo9-addon-mail-as-letter'  Hi...: No module named 'odoo9-addon-mail-as-letter' How to remove the ModuleNotFoundError: No module named 'odoo9-addon-mail-as-letter' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-mail-as-letter'
ModuleNotFoundError: No module named 'odoo10-addon-mail-as-letter'  ...: No module named 'odoo10-addon-mail-as-letter' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-mail-as-letter' error? Thanks
ModuleNotFoundError: No module named 'trytond-account-dunning-letter'
ModuleNotFoundError: No module named 'trytond-account-dunning-letter' ...: No module named 'trytond-account-dunning-letter' How to remove the ModuleNotFoundError: No module named 'trytond-account-dunning-letter' error
ModuleNotFoundError: No module named 'ascii-letter-classifier'
ModuleNotFoundError: No module named 'ascii-letter-classifier'  Hi...: No module named 'ascii-letter-classifier' How to remove the ModuleNotFoundError: No module named 'ascii-letter-classifier' error? Thanks   
Display first letter of every word in uppercase
Display first letter of every word in upper case In this Java tutorial section, you will learn how to display the first letter of every word in uppercase. For this, we have allowed the user to enter the string. The BufferedReader class
java programmming: string manipulation
the command prompt and find the frequency of the character e in the input string...java programmming: string manipulation  WAP to accept a string from the user, using buffered reader and then find the frequency of character 'e
display a list of names(when we press first letter)
("Enter letter: "); String letter=input.next().substring(0,1...: "); String letter=input.next().substring(0,1); System.out.println...display a list of names(when we press first letter)  If i gave
Display set of names in array when we press the first letter
("Enter letter: "); String letter=input.next().substring(0,1... click the starting letter (like in gmail if we press the letter it will show... java.util.*; class DisplaySetOfNames{ public static void main(String[] args
string object
string object  Hi, how do i write a program that works with a user's password, when the program should prompt the user for a possible password, that is between 6 and 10 characters long, that contains at least one letter
Maven Repository/Dependency: org.dkpro.core | dkpro-core-api-frequency-asl
Maven Repository/Dependency of Group ID org.dkpro.core and Artifact ID dkpro-core-api-frequency-asl. Latest version of org.dkpro.core:dkpro-core-api-frequency-asl dependencies. # Version Release Date

Ads