forked from sourabh48/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswap.java
More file actions
40 lines (33 loc) · 917 Bytes
/
swap.java
File metadata and controls
40 lines (33 loc) · 917 Bytes
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
import java.util.*;
public class swap
{
public static void main(String[] args)
{
int x=0,y=0,z=0;
Scanner dis=new Scanner(System.in);
try
{
System.out.println("Enter the first number");
x=dis.nextInt();
System.out.println("Enter the second number");
y=dis.nextInt();
System.out.println("Enter the third number");
z=dis.nextInt();
System.out.println("\n\nBEFORE SWAPING\n\n");
System.out.println("the first number before swaping is: "+x);
System.out.println("the second number before Swaping is: "+y);
System.out.println("the third number before swaping is:"+z);
int temp=0;
temp=x;
x=y;
y=z;
z=temp;
System.out.println("\n\nAFTER SWAPING\n\n");
System.out.println("FIRST NUMBER: "+x);
System.out.println("SECOND NUMBER:"+y);
System.out.println("THIRD NUMBER:"+z);
}
catch(Exception e)
{}
}
}