-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path29.2 Method_N_is_enen_and_multipleof_3.java
55 lines (41 loc) · 1.33 KB
/
29.2 Method_N_is_enen_and_multipleof_3.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Puneet and Virat are playing a game. Virat tells a number that Puneet need to check whether that number is even and multiple of 3 or not. Write a program in which implement a method public boolean check(int n) which will return true if number satisfy the conditions else return false.
Input Format
One integer value representing number given by Virat.
Constraints
Number will lie between 20 and 400.
Output Format
True/False according to the value returned by the method or will print Invalid Input in case of number did not match the constraints.
Sample Input 0
60
Sample Output 0
True
Sample Input 1
12
Sample Output 1
Invalid Input
*/
import java.io.*;
import java.util.*;
public class Solution {
public boolean check(int n)
{
return((n%2==0)&&(n%3==0));
}
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Solution s = new Solution();
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
if(x>=20 && x<=400)
{
boolean answer = s.check(x);
if(answer)
System.out.print("True");
else
System.out.print("False");
}
else
System.out.println("Invalid Input");
}
}