class lower_caseToUpperCase {
public static void main(String[] args)
throws java.io.IOException {
char ch, ignore;
int case_change = 0;
do {
System.out.print("Enter any number of characters: ");
ch = (char) System.in.read();
do {
ignore = (char) System.in.read();
}while(ignore != '\n');
if(ch >= 'a' && ch <= 'z') {
ch -= 32;//shows error if you use ch = ch - 32;
System.out.println(ch);
case_change++;
}
else if(ch >='A' && ch <='Z') {
ch += 32;//same as above
System.out.println(ch);
case_change++;
}
} while(ch != '.');
System.out.print("No. of case changes = " + case_change);
}
}
whenever i use char = char +32 it shows loose conversion error but when i use char += 32 it runs fine. why is it so? please help..