Write a program to print numbers from 258 to 393 except the number end with 5.
output should be like this:
258
259
260
261
262
263
264
266
...
and so on
Solution to the above problem
class problem2{
public static void main(String args[]){
for(int i=258; i<394;i++){
String aString = Integer.toString(i);
char aChar = aString.charAt(2);
String s1 = Character.toString(aChar);
int n = Integer.parseInt(s1);
if(n!= 5){
System.out.println(aString);
}
}
}
}
No comments:
Post a Comment