+ 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
8 Respostas
+ 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);
}
}
+ 5
u can use BufferedReader
+ 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);
}
}
+ 1
thx
but can u do it without scanner class
+ 1
pls
+ 1
leave i got it thanks
+ 1
WAP to calculate the sum of the digits of a number
+ 1
solve this in java