+ 1

How will I do it: WAP to input two numbers and check whether the first number is divisible by the second number.

How to run the program in JAVA

24th Jul 2017, 1:01 PM
Adhiraj Dhar
Adhiraj Dhar - avatar
8 odpowiedzi
+ 5
import java.util.*; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); if(a%b==0) System.out.println(a+" is divisible by "+b); else System.out.println(a+" is not divisible by "+b); } }
24th Jul 2017, 1:21 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 5
u can use BufferedReader
24th Jul 2017, 1:31 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 5
import java.io.*; public class Program { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int a = Integer.parseInt(br.readLine()); int b = Integer.parseInt(br.readLine()); if(a%b==0) System.out.println(a+" is divisible by "+b); else System.out.println(a+" is not divisible by "+b); } }
24th Jul 2017, 4:01 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 1
thx but can u do it without scanner class
24th Jul 2017, 1:22 PM
Adhiraj Dhar
Adhiraj Dhar - avatar
+ 1
pls
24th Jul 2017, 1:23 PM
Adhiraj Dhar
Adhiraj Dhar - avatar
+ 1
leave i got it thanks
24th Jul 2017, 1:25 PM
Adhiraj Dhar
Adhiraj Dhar - avatar
+ 1
WAP to calculate the sum of the digits of a number
24th Jul 2017, 1:27 PM
Adhiraj Dhar
Adhiraj Dhar - avatar
+ 1
solve this in java
24th Jul 2017, 1:27 PM
Adhiraj Dhar
Adhiraj Dhar - avatar