Skip to content
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

#22 challenge #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions November/Day 2/Java/SentenceCapitalisation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.*;
public class SentenceCapitalisation {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input a Sentence: ");
String line = in.nextLine();
String upper_case_line = "";
Scanner lineScan = new Scanner(line);
while(lineScan.hasNext()) {
String word = lineScan.next();
upper_case_line += Character.toUpperCase(word.charAt(0)) + word.substring(1) + " ";
}
System.out.println(upper_case_line.trim());
}
}
Empty file removed November/Day 2/Java/java.java
Empty file.
29 changes: 29 additions & 0 deletions November/Day 22/Java/java.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.util.*;
public class FirstLetterCapital
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter the sentence.");
String s=ob.nextLine();

s=" "+s;
String cap="";
for(int i=0;i<s.length();i++)
{
char x=s.charAt(i);
if(x==' ')
{
cap=cap+" ";
char y=s.charAt(i+1);
cap=cap+Character.toUpperCase(y);
i++;
}
else
{
cap=cap+x;
}
}
System.out.println("The new String with capital letters is: "+"\n"+cap);
}
}