hpilo

Chapter5_Arrays_Ex6

Dec 15th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2. /*
  3. =====================================================
  4. chapter 5: Arrays
  5.  
  6. Ex6: lower case to upper case
  7. =====================================================
  8. */
  9.  
  10.  
  11. public class MyProgram {
  12. public static void main(String[] args) {
  13. final int SIZE=10;
  14. char arr[]=new char[SIZE];
  15. Scanner s=new Scanner(System.in);
  16.  
  17. System.out.println("Enter values: ");
  18. for(int i=0;i<arr.length;i++){
  19. arr[i]=s.next().charAt(0);
  20. }
  21. int i=0;
  22. while(i<arr.length) {
  23. if (arr[i] >= 'A' && arr[i] <= 'Z') {
  24. for (int j = i+1; arr[j] >= 'a'; j++)
  25. arr[j]-=32;
  26. }
  27. i++;
  28. }
  29.  
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment