import javax.swing.JOptionPane;
class Versuch {
private static String time = null;
private static String temp = null;
public static void main(String[] args) {
time = JOptionPane.showInputDialog(null, "Bitte geben sie eine Uhrzeit ein(hhmm):");
temp = JOptionPane.showInputDialog(null, "Bitte geben sie eine Temperatur ein:");
if (time != null && temp != null) {
ausgabe();
}
}
public static void eingabe() {
}
public static int toUStime(int stunde) {
if (stunde == 12) {
return stunde;
} else {
return stunde % 12;
}
}
public static double toUStemp(double celcius) {
return celcius * 9 / 5 + 32;
}
public static boolean ampm(int stunde) {
if (stunde > 12 && stunde < 24) {
return false;
} else {
return true;
}
}
public static void ausgabe() {
int _stunde = toUStime(Integer.parseInt(time.substring(0, 2)));
int _minute = Integer.parseInt(time.substring(2, 4));
boolean _ampm = ampm(Integer.parseInt(time.substring(0, 2)));
double _temp = toUStemp(Double.parseDouble(temp));
JOptionPane.showMessageDialog(null, "Zeit: " + _stunde + " : " + _minute);
if (_ampm == true) {
System.out.println(" am");
} else {
System.out.println(" pm");
}
JOptionPane.showMessageDialog(null, "Temperatur: " + _temp);
}
}