SHOW:
|
|
- or go back to the newest paste.
1 | import java.util.Scanner; | |
2 | import java.lang.Math; | |
3 | import javax.swing.JOptionPane; | |
4 | public class Hauptklasse { | |
5 | ||
6 | public static void main(String[] args) { | |
7 | // TODO Auto-generated method stub | |
8 | ||
9 | double ergebnisMANN; | |
10 | double ergebnisFRAU; | |
11 | ||
12 | ||
13 | Object[] options = {"Mann", "Frau"}; | |
14 | int MannFrau = JOptionPane.showOptionDialog(null, "Bist du ein Mann oder eine Frau?", "KalorienRechner", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); | |
15 | System.out.println(MannFrau); | |
16 | ||
17 | ||
18 | Object[] option = {"nur sitzend oder liegend", "kaum körperliche Aktivität", "sitzend, gehend, stehend", "hauptsächlich stehend und gehend", "körperlich anstrengende Arbeit"}; | |
19 | int Art = JOptionPane.showOptionDialog(null, "Wähle deinen PAL-Wert", "KalorienRechner", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, option, option[0]); | |
20 | System.out.println(Art); | |
21 | ||
22 | String kg = JOptionPane.showInputDialog(null, "Geben sie ihre Kilogramm ein:", "KalorienRechner", JOptionPane.PLAIN_MESSAGE); | |
23 | try{ | |
24 | double kgwert = Double.parseDouble(kg); | |
25 | }catch(Exception e){ | |
26 | JOptionPane.showMessageDialog(null, "Du hast keine Zahl eingegeben!"); | |
27 | } | |
28 | ||
29 | ||
30 | String alter = JOptionPane.showInputDialog(null, "Geben sie ihr Alter ein:", "KalorienRechner", JOptionPane.PLAIN_MESSAGE); | |
31 | try{ | |
32 | double alterwert = Double.parseDouble(alter); | |
33 | }catch(Exception f){ | |
34 | JOptionPane.showMessageDialog(null, "Du hast keine Zahl eingegeben!"); | |
35 | } | |
36 | ||
37 | ||
38 | String groeße = JOptionPane.showInputDialog(null, "Geben sie ihre Größe ein:", "KalorienRechner", JOptionPane.PLAIN_MESSAGE); | |
39 | try{ | |
40 | double groeßewert = Double.parseDouble(groeße); | |
41 | }catch(Exception g){ | |
42 | JOptionPane.showMessageDialog(null, "Du hast keine Zahl eingegeben!"); | |
43 | } | |
44 | ||
45 | ||
46 | if(MannFrau==0){ | |
47 | ergebnisFRAU = 655.1 + (9.6*kg) + (1.8*groeße) - (4.7 * alter); | |
48 | } | |
49 | ||
50 | if(MannFrau==1){ | |
51 | ergebnisMANN = 66.47 + (13.7*kg) + (5*groeße) - (6.8*alter); | |
52 | } | |
53 | ||
54 | ||
55 | ||
56 | } | |
57 | ||
58 | } |