Q:

How can I detect all the capital letters in a string given by the user?

So I'm trying to write a method where it detects all the capital letters given by the user. How is this possible? Is it possible to do it using ASCII values? Is it possible in another way? Please give me suggestions and about the best way to come up with this algorithm
NOTE: problem is as stated at bottom of the source CODE
SOURCE CODE
Scanner sc = new Scanner(System.in);
private String userPassword;
private char[] passChar;
private int passwordScore = 0;

public String getPassword(){
    userPassword = sc.nextLine();
    passChar = userPassword.toCharArray();
    return userPassword;
}
// Ingore this comment below, this is just for me
//do for( char i : passChar.length) or actualy if statmen so that if the pass is not 8 charaters long it doesnt qulafiy
public void passRequirments(){

}

public int passLength(){     
    for(char upperCase: passChar){          
        passwordScore = passwordScore + 4;     
    }

    return passwordScore;
 }

//THIS IS WHERE IM HAVING TROUBLE 
public void passUpper(){        
    for (char c : passChar){          
        if (Character.isUpperCase(passChar.charAt(c))){
        }
    }
}

THE PROBLEM
public void passUpper(){ 
      for (char c : passChar){      
          if (Character.isUpperCase(passChar.charAt(c))){
              passwordScore =  passwordScore + ((userPassword.length()- passChar.charAt(c)) * 2);
          }
      }
  }

A:

I think something like this could be a feasible solution
    import java.io.*;
    import java.util.*;

    public class Main{

      public static int printUpperCaseLetters(String s)
      {
        char[] ch = new char[s.length()];
        ch = s.toCharArray();
        int cap_count = 0;
        for(int i=0; i<ch.length; i++)
        {
          int val = (int)ch[i];
          if(val>=65 && val<=90)
          {
            cap_count++;
            System.out.println(ch[i]);
          }
        }
        return cap_count;
      }

      public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);
        String s = input.next();
        // So this method returns you the capital letters count inside of the string
        int cap_count = printUpperCaseLetters(s);
      }
    }

Hope this help!
You can fetch the function part and add it to your code.
Just focus on the method printUpperCaseLetters and pass your String to this method.

