JAVA: Validating User Input


Hello i was wondering if someone would be able to help me figure out how i can determine whether or not the user entered AT LEAST two upper case letters in their input and AT LEAST one number.

I am currently using a FOR LOOP to run through the given input and am trying to figure out what to do after that. Here is my code:

import javax.swing.JOptionPane;
public class ValidatePassword {

public static void main(String[] args) {
	String originalPw;
	String newPw;
	int pwLength;
	int i;
	char c;
	newPw = JOptionPane.showInputDialog(null, "Please enter a password" + 
	" that contains the following:" + "\n"
	+ "**TWO upper case letters" + "\n" + "**THREE lower case letters" + "\n"
	+ "**ONE number");
	originalPw = newPw;
	pwLength = newPw.length();
	for (i = 0; i <= pwLength; i++) {
		c = newPw.charAt(i);


please give me a tip or explanation as what i am not thinkning of and how i could validate this input.