-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntroJava.java
97 lines (92 loc) · 3.05 KB
/
IntroJava.java
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import javax.swing.*;
public class IntroJava{
public static void saluda(){
String nombre = JOptionPane.showInputDialog("Dime tu nombre");
System.out.println("Hola " + nombre);
}
public static void calificacion(){
String sNota = JOptionPane.showInputDialog("Dime tu nota");
int nota = Integer.parseInt(sNota);
if(nota>=70){
System.out.println("Aprobado " + nota);
}
else{
System.out.println("Reprobado " + nota);
}
}
public static void numeros1al100(){
for(int i = 0; i < 100; i++){
System.out.println(i+1);
}
}
public static void serie(int n){
// int res=0;
for(int i = 0; i < 50; i++){
// res=i*n;
System.out.println((i+1)*n);
}
}
public static int calorias(){
int comidas = Integer.parseInt(JOptionPane.showInputDialog("Dime cuantas comidas haz realizado en el dia: "));
int cal,
total = 0;
for(int i = 0; i < comidas; i++){
cal = Integer.parseInt(JOptionPane.showInputDialog("Dime cuantas calorias consumiste en cada comida: "));
total+=cal;
}
return total;
// JOptionPane.showMessageDialog(null,"Tu total de calorias consumidas es: "+total);
}
public static int mayor(int a, int b, int c){
if(a>b){
if(a>c){
return a;
}
else{
return c;
}
}
else{
if(b>c){
return b;
}
else{
return c;
}
}
}
public static void main(String[] args) {
saluda();
System.out.println(" ");
calificacion();
System.out.println(" ");
numeros1al100();
System.out.println(" ");
int num = Integer.parseInt(JOptionPane.showInputDialog("Dime un numero"));
serie(num);
int calo=calorias();
JOptionPane.showMessageDialog(null,"Tu total de calorias consumidas es: "+calo);
System.out.println(" ");
int x= Integer.parseInt(JOptionPane.showInputDialog("Dime un numero"));
int y = Integer.parseInt(JOptionPane.showInputDialog("Dime otro numero"));
int z = Integer.parseInt(JOptionPane.showInputDialog("Dime otro numero"));
JOptionPane.showMessageDialog(null,"El mayor es: "+mayor(x,y,x));
}
}
// import javax.swing.*;
//
// public class TareaCiclos{
// public static int factores(int num){
// if(num <= 1){
// return 1;
// }
// else{
// return (num*factores(num-1));
// }
// }
// public static void main(String[] args) {
// int x = Integer.parseInt(JOptionPane.showInputDialog("Dime un numero"));
// System.out.println("El factorial del "+ x + " es: " + factores(x));
// // JOptionPane.showMessageDialog(null,"El factorial del "+ x + " es: " + factores(x));
// }
// }