Computer Science, asked by INDIAN04, 1 year ago

java program using scanner to print no.s between 100 to 200 that do not have 0 at any position​


rakeshchennupati143: mark brainliest if you liked my answer

Answers

Answered by rakeshchennupati143
26

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:

  1. first i don't know why did you said "using scanner to print"
  2. anyway i used scanner just as you said and it did not have any purpose though
  3. and i initialized for loop for 1 = 100 up to 200
  4. in loop i kept if statement and check 3 conditions based on "0"
  5. numbers having 0 in between 100 and 200 are which are divisible by 10 and number between 100 to 111  and at last 200
  6. 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   :)


INDIAN04: why i>110 and i!=200.
INDIAN04: sorry
INDIAN04: i mean why have u written i >110 and i!=200
rakeshchennupati143: because 100 to 110 numbers have 0's in them
rakeshchennupati143: and 200 have 0 in it
rakeshchennupati143: and i is the number i'm taking to check weather it has 0's in any of the position or not
rakeshchennupati143: hope you got my point right?
Similar questions