I need to write a program that takes in an input using JOptionPane and make sure it is more than 15 characters, then count the number of uppercases in the phrase. Please help desperate student.

try using isCharacter(), .charAt() and .length

Chris

Hey...this works for a string...maybe you can modify it to what you are wanting:

int count = 0;
		int UpperCaseCount = 0;
		char[] newCharArray = new char[100];
		do {
			System.out.println("Enter a string: ");
			Scanner sc = new Scanner(System.in);
			String theString = sc.nextLine();			
			for (int i=0; i< theString.length(); i++)
			{
				newCharArray[i] = theString.charAt(i);
				count++;			
			}
			System.out.println(count);
			if (count <15)
			{
				System.out.println("String Rejected.");
				count = 0;
				
			}
		} while(count < 15);
		for (int i=0; i < newCharArray.length; i++) {
			char a = newCharArray[i];
			int charVal = a;
			if (charVal > 60 && charVal < 90) {
				UpperCaseCount++;
			}
				
		}
		System.out.println(UpperCaseCount);

It just does not work if the string has white spaces, but you can figure something like that out...it shouldn't be that hard to take it out...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.