This commit is contained in:
PC de clase committed 2026-09-24 12:42:39 +02:00
1 parent 798d2f27fb
commit a43803e1f1
3 files changed
+44

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import java.util.Scanner;
void main() {
Scanner sc = new Scanner(System.in);
boolean llueve;
boolean sol;
int diasRiego;
int diasAbono;
System.out.print("Está lloviendo? ");
llueve = sc.nextBoolean();
sc.nextLine();
System.out.print("Hace sol? ");
sol = sc.nextBoolean();
sc.nextLine();
System.out.print("Cuantos días hace que regaste? ");
diasRiego = sc.nextInt();
sc.nextLine();
System.out.print("Cuantos días hace que abonaste? ");
diasAbono = sc.nextInt();
sc.nextLine();
boolean regar = !(llueve || diasRiego < 5 || sol);
boolean abonar = regar && diasAbono >= 10;
System.out.println("Regar: " + regar + "\nAbonar: " + abonar);
}
+12
View File
@@ -0,0 +1,12 @@
// Corregir y explicar errores
public class Casting1 {
public static void main(String[] args) {
byte edadJuan=20;
int edadPedro=edadJuan+1; // La operación se defaultea a int
short sueldoBase= 1980;
short complementos= 400;
int sueldoTotal;
sueldoTotal=sueldoBase+complementos; // Esta expresión es int
}
}
+6
View File
@@ -0,0 +1,6 @@
void main() {
// Imprimir 1234 justificado a la derecha, en un campo de 10 dígitos.
System.out.printf("%010d\n", 1234);
// Imprimir 3.333333 con un signo (+ o –) en un campo de 20 caracteres, con una precisión de 3
System.out.printf("%+20.3f\n", 3.333333);
}