-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path014.java
More file actions
38 lines (24 loc) · 789 Bytes
/
Copy path014.java
File metadata and controls
38 lines (24 loc) · 789 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
"""
Exercício 14 - Faça um algoritmo que receba um valor A e B, e troque o valor de A por B e o valor de B por A e imprima na tela os valores
"""
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Digite o valor de A: ");
int a = sc.nextInt();
System.out.println("Digite o valor de B: ");
int b = sc.nextInt();
int c = 0;
System.out.println();
System.out.println("Antes da troca (A): " + a);
System.out.println("Antes da troca (B): " + b);
c = a;
a = b;
b = c;
System.out.println();
System.out.println("Depois da troca (A): " + a);
System.out.println("Depois da troca (B): " + b);
sc.close();
}
}