Hi, ich habe hier ein programm geschrieben und möchte am Schluss eine Abfrage machen, ob man das Programm erneut starten möchte.
Hier der Quelltext:
Hier der Quelltext:
Code:
package bmi;
import javax.swing.JOptionPane;
public class BMI {
public static void main(String[] args) {
float Ergebnis = 0;
float Ergebnis2 = 0;
try {
String BMI = JOptionPane.showInputDialog("Bitte gib dein Gewicht in Kg an:");
String bmi = JOptionPane.showInputDialog("Bitte gib nun deine Größe in cm an:");
String Ge = JOptionPane.showInputDialog("Bist du Männlich, oder Weiblich? (M = Männlich; W = Weiblich");
float BMI2 = Float.parseFloat(BMI);
float bmi2 = Float.parseFloat(bmi);
Ergebnis = bmi2 * bmi2;
Ergebnis2 = (BMI2 / Ergebnis) * 10000;
if(Ge.equals("W")) {
if(Ergebnis2 < 19) {
JOptionPane.showMessageDialog(null, "Du bist untergewichtig! Dein BMI: " + Ergebnis2);
}
if((Ergebnis2 >= 19) && (Ergebnis2 <= 24)) {
JOptionPane.showMessageDialog(null, "Dein Gewicht liegt im Normalbereich! Dein BMI: " + Ergebnis2);
}
if(Ergebnis2 > 24) {
JOptionPane.showMessageDialog(null, "Du bist übergewichtig! Dein BMI: " + Ergebnis2);
}
}
if(Ge.equals("M")) {
if(Ergebnis2 < 20) {
JOptionPane.showMessageDialog(null, "Du bist untergewichtig! Dein BMI: " + Ergebnis2);
}
if((Ergebnis2 >= 20) && (Ergebnis2 <= 25)) {
JOptionPane.showMessageDialog(null, "Dein Gewicht liegt im Normalbereich! Dein BMI: " + Ergebnis2);
}
if(Ergebnis2 > 25) {
JOptionPane.showMessageDialog(null, "Du bist übergewichtig! Dein BMI: " + Ergebnis2);
}
}
}
catch(Exception x) {
JOptionPane.showMessageDialog(null, "Es ist ein Fehler aufgetreten!", "Fehler!", JOptionPane.ERROR_MESSAGE);
}
}
}
//Jetzt soll hier eine Abfrage hin, ob man das Programm nochmal ausführen möchte. Aber wie sage ich: "Programm neu starten"?