-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQB 715.java
More file actions
36 lines (29 loc) · 769 Bytes
/
QB 715.java
File metadata and controls
36 lines (29 loc) · 769 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
//QB 715
import java.util.Scanner;
class Ex1 {
int a, b;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a: ");
int a = sc.nextInt();
System.out.println("Enter b: ");
int b = sc.nextInt();
Ex1 ab = new Ex1(a, b);
ab.swap();
ab.display();
}
Ex1(int a, int b) {
this.a = a;
this.b = b;
}
void swap() {
this.a = this.a + this.b;
this.b = this.a - this.b;
this.a = this.a - this.b;
}
void display() {
System.out.println("After Swap numbers are ");
System.out.println("Value of a is " + this.a);
System.out.println("Value of b is " + this.b);
}
}