-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject_3.java
More file actions
43 lines (34 loc) · 1.21 KB
/
Project_3.java
File metadata and controls
43 lines (34 loc) · 1.21 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
40
41
42
43
import java.util.Scanner;
public class Project_3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number for different tasks !!!");
int num = sc.nextInt();
System.out.println("What do you want to check for integer? 1. Odd or Even 2. Square 3. Cube");
int choice = sc.nextInt();
switch(choice) {
case 1:
if (num % 2 == 0) {
System.out.println("The number is even.");
System.out.println("-_-_-_-_-_-_Thank You-_-_-_-_-_-_");
}
else {
System.out.println("The number is odd.");
System.out.println("-_-_-_-_-_-_Thank You-_-_-_-_-_-_");
}
break;
case 2:
int square= num * num;
System.out.println("The square of the number is: " + square);
System.out.println("-_-_-_-_-_-_Thank You-_-_-_-_-_-_");
break;
case 3:
int cube= num * num * num;
System.out.println("The cube of the number is: " + cube);
System.out.println("-_-_-_-_-_-_Thank You-_-_-_-_-_-_");
break;
default:
System.out.println("Invalid choice!");
}
}
}