Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.Math;
- import javax.swing.JOptionPane;
- public class Hauptklasse {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- double ergebnisMANN;
- double ergebnisFRAU;
- Object[] options = {"Mann", "Frau"};
- int MannFrau = JOptionPane.showOptionDialog(null, "Bist du ein Mann oder eine Frau?", "KalorienRechner", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
- System.out.println(MannFrau);
- Object[] option = {"nur sitzend oder liegend", "kaum körperliche Aktivität", "sitzend, gehend, stehend", "hauptsächlich stehend und gehend", "körperlich anstrengende Arbeit"};
- int Art = JOptionPane.showOptionDialog(null, "Wähle deinen PAL-Wert", "KalorienRechner", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, option, option[0]);
- System.out.println(Art);
- String kg = JOptionPane.showInputDialog(null, "Geben sie ihre Kilogramm ein:", "KalorienRechner", JOptionPane.PLAIN_MESSAGE);
- try{
- double kgwert = Double.parseDouble(kg);
- }catch(Exception e){
- JOptionPane.showMessageDialog(null, "Du hast keine Zahl eingegeben!");
- }
- String alter = JOptionPane.showInputDialog(null, "Geben sie ihr Alter ein:", "KalorienRechner", JOptionPane.PLAIN_MESSAGE);
- try{
- double alterwert = Double.parseDouble(alter);
- }catch(Exception f){
- JOptionPane.showMessageDialog(null, "Du hast keine Zahl eingegeben!");
- }
- String groeße = JOptionPane.showInputDialog(null, "Geben sie ihre Größe ein:", "KalorienRechner", JOptionPane.PLAIN_MESSAGE);
- try{
- double groeßewert = Double.parseDouble(groeße);
- }catch(Exception g){
- JOptionPane.showMessageDialog(null, "Du hast keine Zahl eingegeben!");
- }
- if(MannFrau==0){
- ergebnisFRAU = 655.1 + (9.6*kg) + (1.8*groeße) - (4.7 * alter);
- }
- if(MannFrau==1){
- ergebnisMANN = 66.47 + (13.7*kg) + (5*groeße) - (6.8*alter);
- }
- }
- }
Add Comment
Please, Sign In to add comment