Code:
Java:
import javax.swing.JOptionPane;
public class Zahlentest {
public static void main(String[] args) {
String eingabe;
double c;
boolean istpositiv;
eingabe = JOptionPane.showInputDialog("Geben sie die Zahl ein: ");
c = Double.valueOf(eingabe);
if (c > 0) {
istpositiv = true;
} else {
if (c < 0) {
istpositiv = false; }
}
if (istpositiv == true) {
JOptionPane.showMessageDialog(null, c + "ist positiv!"); }
else {
JOptionPane.showMessageDialog(null, c + "ist negativ!"); }
}
}
Zuletzt bearbeitet von einem Moderator: