java program using scanner to print no.s between 100 to 200 that do not have 0 at any position
Answers
Program:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i = 100 ; i <= 200 ; i ++){
if((i % 10 != 0) && (i > 110) && (i != 200)){
System.out.print(i + ",");
}
}
}
}
Output:
111,112,113,114,115,116,117,118,119,121,122,123,124,125,126,127,128, 129,131,132,133,134,135,136,137,138,139,141,142,143,144,145,146, 147,148,149,151,152,153,154,155,156,157,158,159,161,162,163,164, 165,166,167,168,169,171,172,173,174,175,176,177,178,179,181,182, 183,184,185,186,187,188,189,191,192,193,194,195, 196, 197,198,199
Explanation:
- first i don't know why did you said "using scanner to print"
- anyway i used scanner just as you said and it did not have any purpose though
- and i initialized for loop for 1 = 100 up to 200
- in loop i kept if statement and check 3 conditions based on "0"
- numbers having 0 in between 100 and 200 are which are divisible by 10 and number between 100 to 111 and at last 200
- so i used these condition in if case and check each condition if true then only the number will be printed or else the loop iterates and goes no next number
-----Hope you liked my answer, mark brainliest if you liked my answer.And in future if you have any doubts about coding and programming stuff feel free to approach me, i will clarify or in the most cases answer your doubts or problems :)