Computer Science, asked by Komall11, 1 year ago

plz guyz tommorw I have test ...
write a program to input a no. and check whether it is a three digit no. divisible by three or not ...
conditional structure ...
Plz help ...


Anonymous: sum of the digits should be divisible by 3
Komall11: so the program plz if I know
Komall11: u know

Answers

Answered by harindersaini2pcf8vf
0

For Java...   class abc       {                void main(int n)                       {                                 if (n<=999 || n>=100) &&(n%3==0)                    {                                System.out.println(n + " is a three digit number divisible by 3");                                   }                       else                     System.out.println( "Wrong number");                  }              }                         Hope it helps :-)


harindersaini2pcf8vf: Sorry there is a problem in my keyboard so the program has come in this alignment. I am trying to edit it. Hope it helps :-)
Komall11: Hey I don't know java I m just in class seven can u do it with a process of if else
harindersaini2pcf8vf: It has been done with if else only. Actually there is problem in my keyboard that's why it's like that. I'll write it again in the comment box.
harindersaini2pcf8vf: class abc
Answered by Anonymous
0

import java.io.*;

class Divisible

{

public static void main()throws IOException

{

DataInputStream di= new DataInputStream(System.in);

int n;

System.out.println("Enter any number " );

n=Integer.parseInt(di.readLine());

if(n>99 && n<1000 && n%3==0)

System.out.println(" Number is divisible by 3=" +n);

else

System.out.println(" Number is not divisible by 3=" +n);

}

}


Similar questions