-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst.java
More file actions
39 lines (36 loc) · 1.05 KB
/
first.java
File metadata and controls
39 lines (36 loc) · 1.05 KB
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
import java.util.*;
public class first {
public static void main(String[] args){
System.out.println("hello world");
System.out.println("*");
Scanner sc =new Scanner(System.in);//input
String name = sc.next();//for taking input
System.out.println(name);
//conditional statements
int age=sc.nextInt();
if (age>=18)
{
System.out.println("adult");
}
else{
System.out.println("non adult");
}
int num=sc.nextInt();
if(num%2==0){
System.out.println("even");
}else{
System.out.println("odd");
}
//switch case
int button=sc.nextInt();
switch(button){
case 1:System.out.println("Hello");
break;
case 2:System.out.println("Namaste");
break;
case 3:System.out.println("Bonjour");
break;
default:System.out.println("invalid button");
}
}
}