Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
56 lines (46 loc) · 1.61 KB

File metadata and controls

56 lines (46 loc) · 1.61 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
56
#https://www.facebook.com/lakshay.gulati.5/posts/3439658002768650
#subscribed by Lakshay
public class switchcase {
public static void main(String[] args) {
System.out.println("Choose an option:-");
System.out.println("1.To check if the no. is composite");
System.out.println("2.To find the smallest digit");
Scanner scan = new Scanner(System.in);
int choice = scan.nextInt();
int store[];
switch(choice){
case 1:
{
System.out.println("Enter the number");
int num = scan.nextInt();
for (int i = 2;i<num;i++){
if((num%i)==0){
System.out.println("The number is Composite");
break;}
if(i==(num-1)){
System.out.println("The number is prime");
}
else{
continue;}
}
}break;
case 2:
{
System.out.println("Enter the number");
String num1 = scan.next();
store= new int[num1.length()];
int num = Integer.parseInt(num1);
for (int j = 0;j>=0;j++){
if(num==0){
break;}
store[j]=(num%10);
num=num/10;
}
Arrays.sort(store);
System.out.println(store[0]);
}break;
default:{
System.out.println("Enter the Correct choice");}break;
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.