As I continue my study on Java I have discovered that Java programming language has many built in functions that makes programming much easier and more fun specially we are working with strings. I enjoy every minute working with Java. No wonder there are many programmers, developers and software engineers find it very useful in many programming project because it is a very versatile programming language.
If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at my mobile number 09173084360.
Thank you very much and Happy Programming.
Sample Program Output
Program Listing
// find_upper_case.java
// Programmer : Mr. Jake R. Pomperada, MAED-IT
// Date : August 5, 2015
// Tools : Netbeans 8.0.2
// Email : jakerpomperada@yahoo.com and jakerpomperada@gmail.com
// Write a program that will conver the first letter of a word into capital
// letters
import java.util.Scanner;
public class find_upper_case {
public static String Upper_First_Letter(String str)
{
boolean check_space = true;
char[] chars = str.toCharArray();
for (int a = 0; a < chars.length; a++) {
if (Character.isLetter(chars[a])) {
if (check_space) {
chars[a] = Character.toUpperCase(chars[a]);
}
check_space = false;
} else {
check_space = Character.isWhitespace(chars[a]);
}
}
return new String(chars);
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
char ch;
do {
String sentence,repeat;
repeat = input.nextLine();
System.out.print("FIRT LETTER CAPITAL PROGRAM");
System.out.println();
System.out.print("Enter a Sentence : ");
sentence = input.nextLine();
System.out.println();
System.out.println("ORIGINAL SENTENCE");
System.out.print(sentence);
System.out.println("\n\n");
System.out.println("CONVERTED SENTENCE");
System.out.print(Upper_First_Letter(sentence));
System.out.println();
System.out.print("\nDo you want to continue (Type y or n) : ");
ch = input.next().charAt(0);
} while (ch == 'Y'|| ch == 'y');
System.out.println();
System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
System.out.println();
}
}
// Programmer : Mr. Jake R. Pomperada, MAED-IT
// Date : August 5, 2015
// Tools : Netbeans 8.0.2
// Email : jakerpomperada@yahoo.com and jakerpomperada@gmail.com
// Write a program that will conver the first letter of a word into capital
// letters
import java.util.Scanner;
public class find_upper_case {
public static String Upper_First_Letter(String str)
{
boolean check_space = true;
char[] chars = str.toCharArray();
for (int a = 0; a < chars.length; a++) {
if (Character.isLetter(chars[a])) {
if (check_space) {
chars[a] = Character.toUpperCase(chars[a]);
}
check_space = false;
} else {
check_space = Character.isWhitespace(chars[a]);
}
}
return new String(chars);
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
char ch;
do {
String sentence,repeat;
repeat = input.nextLine();
System.out.print("FIRT LETTER CAPITAL PROGRAM");
System.out.println();
System.out.print("Enter a Sentence : ");
sentence = input.nextLine();
System.out.println();
System.out.println("ORIGINAL SENTENCE");
System.out.print(sentence);
System.out.println("\n\n");
System.out.println("CONVERTED SENTENCE");
System.out.print(Upper_First_Letter(sentence));
System.out.println();
System.out.print("\nDo you want to continue (Type y or n) : ");
ch = input.next().charAt(0);
} while (ch == 'Y'|| ch == 'y');
System.out.println();
System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
System.out.println();
}
}