Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners count characters
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


siti umairah
count characters
2 Answer(s)      2 years and 7 months ago
Posted in : Java Beginners


i have to print the total number of char 'A' in all string entered..

example: please enter your string: selangor melaka kedah sabah sarawak terengganu

the output must be count the total number of char 'A'...


Advertisement
View Answers

March 1, 2012 at 10:30 AM


import java.util.*;

class CountCharacter
{
    public static void main(String[] args) 
    {
        int count=0;
        Scanner input=new Scanner(System.in);
        System.out.print("Enter string: ");
        String str=input.nextLine();

        char arr[]=str.toLowerCase().toCharArray();
        for(int i=0;i<arr.length;i++){
            if(arr[i]=='A'||arr[i]=='a'){
                count++;
            }
        }
        System.out.println("Character occurs "+count+" times");
    }
}


March 1, 2012 at 10:30 AM


import java.util.*;

class CountCharacter
{
    public static void main(String[] args) 
    {
        int count=0;
        Scanner input=new Scanner(System.in);
        System.out.print("Enter string: ");
        String str=input.nextLine();

        char arr[]=str.toLowerCase().toCharArray();
        for(int i=0;i<arr.length;i++){
            if(arr[i]=='A'){
                count++;
            }
        }
        System.out.println("Character occurs "+count+" times");
    }
}


Related Tutorials/Questions & Answers:
count characters
count characters  i have to print the total number of char 'A' in all... sabah sarawak terengganu the output must be count the total number of char... main(String[] args) { int count=0; Scanner input=new Scanner
Count number of characters in a column.
Count number of characters in a column.  I just need you suggestions. Am from Biology Back ground. I just need to find out number of characters... to count characters in 1st, 2nd, 3rd columns seperatly and also print flase if i
Advertisements
Count characters from text file in Java
Count characters from text file in Java  At the "Count chracters fro... is a java code that count the occurrence of each character from text file. import...++){ char ch= third[counter]; int count=0; for ( int i=0; i<third.length; i
Java count characters from file
Java count characters from file In this section, you will learn how to count characters from the file. Description of code: Firstly, we have used FileReader... into character array in order to count the occurrence of each character
Count Characters from the input string Java
Count Characters from the input string of Java In this section, you will learn how to count the occurrence of each character in the string. For this, we have... to count the occurrence of each character of the array.  Here is the code
Count characters from text file in Java
Count characters from text file Using Java Here we are going to count... it into character array in order to count the occurrence of each character...;ch= third[counter];   int count=0;   for 
Java Word Count - Word Count Example in Java
to count the number of lines, number of words and number of characters... some strings and program will count the number of characters and number of words... of characters, number of lines. To count the number of words call
Java characters
Java characters  How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters
Unwanted characters instead of arabic characters
Unwanted characters instead of arabic characters  I am using... and using it to display. the problem is: I need to display some arabic characters here... ص??د??ة س??د ?????أرب like characters instead of arabic
count in hibernate .
count in hibernate .  How to implements count in hibernate
Count the character in java
.   Count characters by implementing thread import java.util.*; class...[]=st.toCharArray(); int count=ch.length; System.out.println("Total Characters...Count the character in java  Write a java program to count
count the users?
count the users?  how to get the number of users logged in any application
Count number of "*"
Count number of "*"  I have this code to count the number of * from...:"); String text = bf.readLine(); int count = 0; for (int i = 0; i...); if (c=='*' ) { count
Character count by while loop
Count Characters...Character count by while loop  Write the program to count the number of characters entered until a full stop (.)is keyed-in. Anyone there pls help
Count Vowels
Count Vowels   Read a string from the user, your program counts the number of vowels in the text and have it report a sum of each vowel found as well as the number of spaces. Make it in two classes
Protect Special Characters.
Protect Special Characters.  How To Protect Special Characters in Query String
special characters in my HTML
special characters in my HTML  How do I get special characters in my HTML
special characters in my HTML
special characters in my HTML  How do I get special characters in my HTML
characters java - Java Beginners
.(REmember that the alphabet contains 52 characters if you count uppercase... " +str + " has " +j +" characters"); System.out.println(""); } int count(char...characters java  HELLO MAM AND SIR I ASK YOUR HELP HOPE YOU GONNA
remove special characters iphone
remove special characters iphone  remove special characters iphone   Remove special characters iphone from Password NSString *outputString = [passwordString stringByReplacingOccurrencesOfString:@"%" withString
regular expression for special characters
regular expression for special characters  How to find out regular expression for special characters
PDF Generation for unicode characters
PDF Generation for unicode characters  Hi, How a PDF file having unicode characters is generated in JSP
replace special characters in html
replace special characters in html  How can i replace the special characters in HTML?   Special Character in HTML HTML has a long list of special characters symbol that can be used anywhere throughout the HTML Code
Removing characters from a string
Removing characters from a string  Removing characters from a string   Example: public class CharReplace{ public static void main(String []args){ String str="Hello 123.you are At 3456"; String
Uppercase Characters in Java
Uppercase Characters in Java  I want to know how to UpperCase Characters in Title useing a java code...?   Use toUpperCase() method to convert the string in uppercase letters. class UppercaseString { public static
Count Rows - JSP-Servlet
Count Rows  How to count rows in Java. Thanks
count objects php
count objects php  How to Count and show objects in PHP
Limiting characters - JSP-Servlet
Limiting characters  Iam doing a jsp project. In this i have a text area which should accept not more than 300 characters. I solved this with backspace and delete keys. But, i cannot solve problem of pasting through shortcut ctrl
Remove unknown characters php - PHP
Remove unknown characters php  i am looking for a script that can remove unknown characters in PHP code except white spaces
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 you feel today?". The answer should be 5. but i still have error compiling
SQLl query count and group by
SQLl query count and group by  How to write a sql query to count and group by the data?   Sql query to count the data and group the data using group by function... Select Name, Count(Name) As Count From Table Group
Advertisements
 

 

 

DMCA.com