fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scanner = new Scanner(System.in);
  13. String ename; // input string
  14. System.out.println("Enter Employee Name : (Type -Name-, not -name-, not -NAME-!!!");
  15. ename = scanner.nextLine(); // read the string input
  16. char[] Transform = new char[ename.length()]; // this array will contain the string split in characters
  17. for (int i = 0;i < ename.length(); i++)
  18. {
  19. Transform[i] = ename.charAt(i); // Split the input to a char array
  20. }
  21. Transform[0] = Character.toUpperCase(Transform[0]); // First Letter Always Capital
  22. for (int i = 1;i < ename.length(); i++)
  23. {
  24. Transform[i] = Character.toLowerCase(Transform[i]); // Other letters small
  25. }
  26. String name = new String(Transform); // convert the array to a new String variable
  27. System.out.println("NEW STRING : " + name );
  28. }
  29. }
Success #stdin #stdout 0.14s 321088KB
stdin
singhakash
stdout
Enter Employee Name : (Type -Name-, not -name-, not -NAME-!!!
NEW STRING : Singhakash