Conversion of string to Capital letters
Problem: Write a program that reads one line of text and then prints it with all its letters capitalized.
Hello all,
I have solved the problem very simple way. But i need more ways. can anybody help me to do this others ways.
Here is my code and it works fine.
public class CapitalizedLetters
{
static String input;
public static void main(String args[])
{
input = "Ripon Al Wasim";
System.out.println(getCapital(input));
}
static String getCapital(String s)
{
//char c[] = s.charArray();
s = input;
String ss = input.toUpperCase();
return ss;
}
}//end class CapitalizedLetters
Thanking u,
Ripon
Does using Arrays.sort(...) count as implementing a sorting routine?
hint: you are on the right track using char[] c = s.charArray();
Try doing the following:
char f = 'a';
for (int i = 0; i < 30; i++) {
f = f + 1;
System.out.print("" + f + " ");
}
1) you could retrieve the input String using command line argument
2) you could retrieve the input String using Swing GUI
3) you could use a for loop to turn each individual char to uppercase and then concatenate
4) you could use the StringBuffer class to do it
Hope this helps!
well as there is a method already 'stringID.toUpperCase()' why write a method?
Manually, its not so very hard - - - > psuedo-code
1. for loop(Condition 0=>number of chars) // cycle through the chars 1 at a time
2. int anInt = (cast to int) the next char
3. if('anInt' > 96 AND anInt < 123) // ascii lower case chars
4. (then do) anInt = anInt - 32 // ascii 'a' = 97 - - - ascii 'A' = 65
5. the next char = (cast to char) anInt
6. end 1 iteration of the loop
as for getting a string of chars to do this ... OK;-
String input = javax.swing.JOptionPane.showInputDialog("Enter a sentence for processing: ");