Professional Documents
Culture Documents
Assignment 18 07-12-23
Assignment 18 07-12-23
A.Y. 2023-24
ASSIGNMENT – 18
1. Write a program to accept a sentence from the user and convert the
first character of every word to uppercase and also punctuate every
word with a dot.
import java.util.*;
public class StringCaseChange2
{
public void stringConvert(String s)
{
s = " " + s;
String cs = "";
char ch;
}
else if(Character.isWhitespace(ch))
{
ch = Character.toUpperCase(s.charAt(i+1));
cs = cs + "." + ch;
i++;
}
else
cs += ch;
}
System.out.println("The original string is: " +
s.trim());
Enter a sentence:
Welcome to java
The original string is: Welcome to java
The converted string is: Welcome.To.Java