Wap to enter a number which must be >9 and <100 and check if it is divisible by 3 ,5 or both 3 and 5 or not , using nested if .
Share
Wap to enter a number which must be >9 and <100 and check if it is divisible by 3 ,5 or both 3 and 5 or not , using nested if .
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
The given problem is solved using language Java.
import java.util.Scanner;
public class Brainly{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number (10-99): ");
int n=sc.nextInt();
if(n%5==0){
if(n%3==0)
System.out.println("Number is divisible by both 5 and 3.");
else
System.out.println("Number is divisible by 5 but not by 3.");
}
else if(n%3==0)
System.out.println("Number is divisible by 3 but not by 5.");
else
System.out.println("Number is neither divisible by 3 and 5.");
sc.close();
}
}
#1
Enter a number (10-99): 25
Number is divisible by 5 but not by 3.
———————————————————————
#2
Enter a number (10-99): 12
Number is divisible by 3 but not by 5.
———————————————————————
#3
Enter a number (10-99): 15
Number is divisible by both 5 and 3.
———————————————————————
#4
Enter a number (10-99): 14
Number is neither divisible by 3 and 5.
Answer:
my sister's intro name mehak class 10th nice to meet you