-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIf26.java
More file actions
23 lines (20 loc) · 529 Bytes
/
If26.java
File metadata and controls
23 lines (20 loc) · 529 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package ifdirect;
import java.util.Scanner;
public class If26 {
public static void main(String[] args) {
Scanner scanner=new Scanner (System.in);
int x,fx;
System.out.print ("X:");
x=scanner.nextInt ();
if (x<=0){
fx=x*(-1);
System.out.println (fx);
} else if (0<x && x<2) {
fx= (int) Math.pow(x,2);
System.out.println (fx);
} else if (x>=2) {
fx=4;
System.out.println (fx );
}
}
}