-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEjercicio2.java
More file actions
50 lines (40 loc) · 1.03 KB
/
Copy pathEjercicio2.java
File metadata and controls
50 lines (40 loc) · 1.03 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
44
45
46
47
48
49
50
package copilotEjercicios;
import java.util.Scanner;
public class Ejercicio2 {
public static void main(String[] args) {
/*
* Ejercicio 2: Mayor de tres números
* Problema: Escribe un programa en Java que determine el mayor
* de tres números.
*/
//atributos
Scanner entrada = new Scanner (System.in);
int a, b, c;
int mayor;
System.out.println("Ingrese un valor A:");
a=entrada.nextInt();
System.out.println("Ingrese un valor B:");
b=entrada.nextInt();
System.out.println("Ingrese un valor C:");
c=entrada.nextInt();
if((a==b) && (b==c)) {
System.out.println("los tres valores son iguales");
}else {
if(a > b) {
if(a>c) {
mayor=a;
System.out.println("el mayor es " + a);
}else {
mayor=c;
System.out.println("el mayor es " + c);
}
}else if(b>c) {
mayor =b;
System.out.println("el mayor es " + b);
}else {
mayor = c;
System.out.println("el mayor es " + c);
}
}
}
}