Hello all,
I was trying to write a program which will print the even indexes of the given sentence.The program supposed to make
them upper case if they are lower case and vice-versa. But I got the following errors:
error: cannot find symbol line 26
error: char cannot be dereferenced line 28
Can you please help me with that?
Thank you in advance
I was trying to write a program which will print the even indexes of the given sentence.The program supposed to make
them upper case if they are lower case and vice-versa. But I got the following errors:
error: cannot find symbol line 26
error: char cannot be dereferenced line 28
Can you please help me with that?
Thank you in advance
import java.util.Scanner;
/**
* @(#)E03012013.java
*
* E03012013 application
*
* @author
* @version 1.00 2013/1/3
*/
public class E03012013 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter your name: ");
String name = scan.nextLine();
int in;
for(int index1 = 0; index1 <= name.length()-1; index1 = index1 +2)
{
in =(int) name.charAt(index1);
if(in <= 90 && in >= 65)
name.charAr(index1).toLowerCase();
if(in <= 122 && in >=97)
name.charAt(index1).toUpperCase();
System.out.print(name.charAt(index1) + " ");
}
}
}