Use the andoperators Write a program that prompts the user

(Use the &&, || and^operators) Write a program that prompts the user to enter an integer and determines whether it is divisible by 5 and 6, whether it is divisible by 5 or 6, and whether it is divisible by 5 or 6, but not both. Here is a sample run of this program: Enter an integer: 10 Is 10 divisible by 5 and 6? False Is 10 divisible by 5 or 6? true Is 10 divisible by 5 or 6, but not both? true Suppose a right triangle is placed in a plane as shown below. The right-angle point is placed at (0, 0), and the other two points are placed at (200, 0), and (0, 100). Write a program that prompts the user to enter a point with x- and y-coordinates and determines whether the point is inside the triangle. Here are the sample runs:

Solution

package sample;

import java.util.Scanner;

public class test {

public static void main(String args[]){

System.out.println(\"enter an integer : \");

Scanner s = new Scanner(System.in);

int n=s.nextInt();

System.out.println(\"Is\"+n+\" divisible by 5 and 6 ? : \"+((n%5==0)&&(n%6==0)));

System.out.println(\"Is\"+n+\" divisible by 5 or 6 ? : \"+((n%5==0)||(n%6==0)));

System.out.println(\"Is\"+n+\" divisible by 5 or 6, but not both ? : \"+(((n%5==0)||(n%6==0))&&!((n%5==0)&&(n%6==0))));

}

}

 (Use the &&, || and^operators) Write a program that prompts the user to enter an integer and determines whether it is divisible by 5 and 6, whether it

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site