Skip to content

CamelCase.java using function #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,29 @@
* @author Kanahaiya Gupta
*
*/
public class CamelCase {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int count = 1;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) >= 65 && s.charAt(i) <= 90) {
count++;
}
}
System.out.println(count);
sc.close();

}
class Solution
{
public static void main(String args[])throws IOException
{
Scanner sc=new Scanner(System.in);
String s;
s=sc.next();
System.out.println(camelCase(s));
}
public static int camelCase(String s)
{
int c,n,i,x;
char p=' ';
s=s+" ";
c=1;
n=s.length();
for(i=0;i<n;i++)
{
p=s.charAt(i);
x=(int)p;
if((x>=65)&&(x<=90))
c++;
}
return c;
}
}