Skip to content

Commit ba666f4

Browse files
Create 29.2 Method_N_is_enen_and_multipleof_3.java
1 parent bd38744 commit ba666f4

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
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.
3+
4+
Input Format
5+
6+
One integer value representing number given by Virat.
7+
8+
Constraints
9+
10+
Number will lie between 20 and 400.
11+
12+
Output Format
13+
14+
True/False according to the value returned by the method or will print Invalid Input in case of number did not match the constraints.
15+
16+
Sample Input 0
17+
18+
60
19+
Sample Output 0
20+
21+
True
22+
Sample Input 1
23+
24+
12
25+
Sample Output 1
26+
27+
Invalid Input
28+
*/
29+
import java.io.*;
30+
import java.util.*;
31+
32+
33+
public class Solution {
34+
35+
public boolean check(int n)
36+
{
37+
return((n%2==0)&&(n%3==0));
38+
}
39+
public static void main(String[] args) {
40+
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
41+
Solution s = new Solution();
42+
Scanner sc = new Scanner(System.in);
43+
int x = sc.nextInt();
44+
if(x>=20 && x<=400)
45+
{
46+
boolean answer = s.check(x);
47+
if(answer)
48+
System.out.print("True");
49+
else
50+
System.out.print("False");
51+
}
52+
else
53+
System.out.println("Invalid Input");
54+
}
55+
}

0 commit comments

Comments
 (0)