Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: how to search for upper/lower case using string using JAVA!!!?

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to search for upper/lower case using string using JAVA!!!?

    -I am trying to write a program that will examine each letter in the string and count how many time the upper-case letter 'E' appears, and how many times the lower-case letter 'e' appears.

    -I also have to use a JOptionPane.showMessageDialog() to tell the user how many upper and lower case e's were in the string.

    -This will be repeated until the user types the word "Stop".

    please help if you can
    what i have so far:

     
    public class Project0 {
     
    	public static void main(String[] args) {
     
    		String[] uppercase = {'E'};
    		String[] lowercase = {'e'};
    		String isOrIsNot, inputWord;
     
    		while (true) {
    			// This line asks the user for input by popping out a single window
    			// with text input
    			inputWord = JOptionPane.showInputDialog(null, "Please enter a sentence");
     
    			if ( inputWord.equals("stop") )
    				System.exit(0);
     
    			// if the inputWord is contained within uppercase or 
    			// lowercase return true
    			if (wordIsThere(inputWord, lowercase)) 
    				isOrIsNot = "Number of lower case e's: "; 
     
    			if (wordIsThere(inputword, uppercase))
    	 			isOrIsNot = "number of upper case e's: ";
     
    			// Output to a JOptionPane window whether the word is on the list or not
    			JOptionPane.showMessageDialog(null, "The word " + inputWord + " " + isOrIsNot + " on the list.");
    		}
    	} //main
     
    	public static boolean wordIsThere(String findMe, String[] theList) {
    		for (int i=0; i<theList.length; ++i) {
    			if (findMe.equals(theList[i])) return true;
    		}
     
    		return false;
    	} // wordIsThere
    } // class Lab4Program1


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 168 Times in 159 Posts

    Default Re: how to search for upper/lower case using string using JAVA!!!?

    Your post is basically "Here's my code, fix it for me because I'm lazy".

    If you want help then ask a specific question.

    BTW creating an array to hold a single value is a waste of resources.
    Improving the world one idiot at a time!

  3. #3
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    610
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: how to search for upper/lower case using string using JAVA!!!?


  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,974
    Thanks
    52
    Thanked 2,269 Times in 2,241 Posts

    Default Re: how to search for upper/lower case using string using JAVA!!!?

    Also posted at How to search for upper/lower case using string in JAVA!!!? - Dev Shed
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Fastest way to read and search a string in a large file using core java
    By patilsn_jay in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: November 26th, 2012, 03:35 AM
  2. Fastest way to read and search a string in a large file using java
    By patilsn_jay in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 24th, 2012, 08:29 AM
  3. how to ignore upper and lower case
    By mohamed_saleh2012 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2012, 02:49 PM
  4. wanting to convert printout to UPPER case
    By welikedogs in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 3rd, 2010, 01:22 PM
  5. [SOLVED] upper case
    By andaji in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 13th, 2010, 10:54 PM

Tags for this Thread