java help!! count number of upper and lower case letters


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: java help!! count number of upper and lower case letters

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Location
    baguio city
    Posts
    2

    java help!! count number of upper and lower case letters

    could someone help me with this.. thanks in advance!!!

    Write a program that allows you to input a string. Your program will count and extract and display the number of upper case letters and lower case letters.
    Sample output:
    Enter a string: Hello World
    Upper case letters: 2 - HW
    Lower case letters: 8 elloorld

  2. #2
    Join Date
    Oct 2010
    Location
    baguio city
    Posts
    2

    finally im done with it.......

    here is what i did ....... hope this reference can help to newbies like me..
    Code:
    import java.io.*;
    public class casestudy4 {
    
    	public static void main(String[] args)throws IOException {
    		BufferedReader enterstring=new BufferedReader(new InputStreamReader(System.in));		
    		
    		String inputstring;
    		String upper ="";
    		String lower ="";
    		String other ="";
    		
    		System.out.print("Enter a String: ");
    		inputstring=enterstring.readLine();
    		
    		for (int i = 0; i < inputstring.length(); i++) {
    		    char thisChar = inputstring.charAt(i);
    		    if (thisChar >= 65 && thisChar <= 90) {
    		    	upper += thisChar;
    		    } else if (thisChar >= 97 && thisChar <= 122) {
    		    	lower += thisChar;
    		    }  else {
    		    	other += thisChar;
    		    }
    		}
    		System.out.println("Upper case letters: " + upper.length() + " - " + upper);
    		System.out.println("Lower case letters: " + lower.length() + " - " + lower);
    		System.out.println("Other: "+other);
        }
    }
    thread close......
    Last edited by Hack; 10-28-2010 at 12:06 PM. Reason: Added Code Tags

  3. #3
    Join Date
    Oct 2010
    Posts
    10
    great going....

Similar Threads

  1. errors with some varibles
    By ELHEK in forum Java
    Replies: 1
    Last Post: 10-01-2006, 06:08 PM
  2. pleeese help me i am sooo stuck
    By christopher in forum Java
    Replies: 4
    Last Post: 12-19-2002, 01:31 PM
  3. When to use UPPER and LOWER
    By Auseve in forum Database
    Replies: 1
    Last Post: 03-20-2002, 07:59 PM
  4. Re: Unset the Case Sensitivity of Oracle - LOWER( )
    By Myles Waito in forum Database
    Replies: 1
    Last Post: 05-07-2001, 02:53 AM
  5. Replies: 2
    Last Post: 07-07-2000, 02:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center