DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

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 11:06 AM. 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, 05:08 PM
  2. pleeese help me i am sooo stuck
    By christopher in forum Java
    Replies: 4
    Last Post: 12-19-2002, 12:31 PM
  3. When to use UPPER and LOWER
    By Auseve in forum Database
    Replies: 1
    Last Post: 03-20-2002, 06:59 PM
  4. Re: Unset the Case Sensitivity of Oracle - LOWER( )
    By Myles Waito in forum Database
    Replies: 1
    Last Post: 05-07-2001, 01:53 AM
  5. Replies: 2
    Last Post: 07-07-2000, 01:48 PM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links