I need to write a program where it will ask the user to write a sentence and count the upper case and lower case alphabet 'e'. I.E- number of lower case e is say 4 and number of upper case E is 3. Every tree is not an Elm,Emile. and it should keep asking the user to enter sentences till the user writes stop to stop the program.any idea?

>any idea?
I actually don't quite get the question of your assignment.
Also I see no code I can help you with.

But I know some interesting code which can help you to get help, here on this forum:

Effort opEffort;

if(opEffort == null) {
    System.out.println("You should urgently stop right here and think about your assignment.");
    System.out.println("Give it a try before moving on to a forum to ask for help.");
    System.out.println("When you're finished writing some code, and then get stuck, move on to a forum,");
    System.out.println("post down your code, and ask for help.");
}

(The pseudo-code can be found here).

Edited 7 Years Ago by mvmalderen: fix some things

here is my code but its not running. And i need specific letter to be counted .Dont know how to do that.

public class project0 {
    public static void main(String args[]){
        if(args.length == 0){
        System.out.println("Enter a sentence.");
        System.exit(1);
        }
        String s = args[0];
        int upper = 0, lower = 0;
        for(int i = 0; i < s.length(); i++){
        if(Character.isUpperCase(s.charAt(i))) upper++;
        if(Character.isLowerCase(s.charAt(i))) lower++;
        }
        System.out.println("There are:\n" +
        upper + " uppercase characters\n" +
        lower + " lowercase characters\n");
    }
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

ok here i am getting it to ask to enter a sentence but then not working. :(
import javax.swing.JOptionPane;

public class project0 {
    public static String inputWord;
    public static void main(String args[]){
        inputWord = JOptionPane.showInputDialog(null,"Enter a sentence.");
        while (!inputWord.equals("stop"))
        if(args.length == 0){
        //System.out.println("Enter a sentence.");
        //System.exit(1);
        }
        String s = args[0];
        int upper = 0, lower = 0;
        for(int i = 0; i < s.length(); i++){
        if(Character.isUpperCase(s.charAt(i))) upper++;
        if(Character.isLowerCase(s.charAt(i))) lower++;
        }
        System.out.println("There are:\n" +
        upper + " uppercase characters\n" +
        lower + " lowercase characters\n");
    }
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class AlphabetCounter {

	public static void main(String[] args) {
		String temporary = "Hi this is javed and you are learning java programming language";
		char[] charArray = temporary.toCharArray();
		HashMap<Character, Integer> hashMap = new HashMap<Character, Integer>();
		for (int i = 0; i < charArray.length; i++) {
			int charCounter = 0;
			for (int j = 0; j < charArray.length; j++) {
				if (charArray[i] == charArray[j]) {
					charCounter++;
				}
			}
			hashMap.put(charArray[i], charCounter);
		}
		Set<Character> alphabets = hashMap.keySet();
		for (Iterator iterator = alphabets.iterator(); iterator.hasNext();) {
			Character character = (Character) iterator.next();
			System.out.println(character + " occured " + hashMap.get(character)
					+ " times");
		}
	}
}

SNIP

Edited 7 Years Ago by happygeek: spam deleted

After 25 posts it's certainly time to become familiar with something which is utterly important on this forum.
Most people call it "code tags".

Even with all the help available on code tags, you don't seem to know about them (which unfortunately is a bad thing).
Just a small list on what places you were encouraged to find out what code tags are:

  1. in the Rules you were asked to read when you registered.
  2. in the text at the top of this forum.
  3. in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags.
  4. in the sticky post above titled Read Me: Read This Before Posting
  5. any place CODE tags were used.
  6. Even on the background of the box you actually typed your message in.

Edited 7 Years Ago by mvmalderen: fix some small things

This article has been dead for over six months. Start a new discussion instead.