Skip to content

Instantly share code, notes, and snippets.

@duranangie
Created May 18, 2024 20:41
Show Gist options
  • Save duranangie/9b09dbade65168bc105e86b37304258e to your computer and use it in GitHub Desktop.
Save duranangie/9b09dbade65168bc105e86b37304258e to your computer and use it in GitHub Desktop.
package temperatura;
import java.util.Scanner;
public class temperatura {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String nombre[] = new String[5];
double maxima[] = new double[5];
double minima[] = new double[5];
for (int i = 0; i < nombre.length; i++) {
System.out.println("escribe nombre de la ciudad");
nombre[i] = scan.next();
System.out.println("escribe temperatura max de la ciudad");
maxima[i] = scan.nextDouble();
System.out.println("escribe temperatura min de la ciudad");
minima[i] = scan.nextDouble();
}
int temMax = -1;
int temMin = -1;
double maximas = -9999999.00;
double minimas = 9999999.00;
for (int i = 0; i < nombre.length; i++) {
if (maxima[i] > maximas) {
maximas = maxima[i];
temMax = i;
}
if (minima[i] < minimas) {
minimas = minima[i];
temMin = i;
}
}
System.out.println(maximas);
System.out.println(nombre[temMax]);
System.out.println(minimas);
System.out.println(nombre[temMin]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment