first commit

This commit is contained in:
PC de clase committed 2026-09-21 12:36:00 +02:00
commit 6ad15af53b
8 files changed
+119

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import java.util.Scanner;
public class RadaresDeTramo {
public static void main() {
Scanner sc = new Scanner(System.in);
int distancia = 0; // Distancia entre las cámaras (metros)
int velPermitida = 0; // Velocidad máxima permitida (Km/h)
int tiempo = 0; // Tiempo que tarda el coche en pasar entre las cámaras (segundos)
while(true) { // Condición de salida después de obtener datos
System.out.print("Introduce los datos: ");
distancia = sc.nextInt();
velPermitida = sc.nextInt();
tiempo = sc.nextInt();
sc.nextLine(); // Limpiar stdin
// Salir del bucle
if (distancia == 0 && velPermitida == 0 && tiempo == 0) {
System.out.println("SALIR");
break;
}
// Calcular
double velocidad = (distancia / 1000.0) / (tiempo / 3600.0); // m/s => Km/h
if (velocidad > velPermitida){
// indicará "MULTA" si se superó esa velocidad en menos de un 20% de la velocidad máxima permitida,
// y "PUNTOS" si la velocidad fue superada en un 20% o más de esa velocidad;
double rangoMulta = velPermitida * 20 / 100; // Rango que decide si te multan o te quitan puntos
if(velocidad < velPermitida + rangoMulta){
System.out.println("MULTA");
} else {
System.out.println("PUNTOS");
}
} else {
System.out.println("OK");
}
}
}
}
+13
View File
@@ -0,0 +1,13 @@
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
void main() {
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
IO.println(String.format("Hello and welcome!"));
for (int i = 1; i <= 5; i++) {
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
IO.println("i = " + i);
}
}