summaryrefslogtreecommitdiff
path: root/ws2015/eip/blaetter/02/Arithmetik.java
diff options
context:
space:
mode:
Diffstat (limited to 'ws2015/eip/blaetter/02/Arithmetik.java')
-rw-r--r--ws2015/eip/blaetter/02/Arithmetik.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/ws2015/eip/blaetter/02/Arithmetik.java b/ws2015/eip/blaetter/02/Arithmetik.java
new file mode 100644
index 0000000..90335a4
--- /dev/null
+++ b/ws2015/eip/blaetter/02/Arithmetik.java
@@ -0,0 +1,33 @@
1import java.util.Scanner;
2
3class Arithmetik
4{
5 public static void main (String[] args)
6 {
7 Scanner scanner = new Scanner(System.in);
8
9 System.out.print("Vorname: ");
10 String vorname = scanner.nextLine();
11 System.out.print("Nachname: ");
12 String nachname = scanner.nextLine();
13 System.out.print("x_1 = ");
14 int x1 = scanner.nextInt();
15 System.out.print("x_2 = ");
16 int x2 = scanner.nextInt();
17
18 System.out.print("Hallo " + vorname.substring(0,1) + ". " + nachname + "! ");
19
20 if (x1 < x2)
21 {
22 System.out.println("Der Mittelwert von " + x1 + " und " + x2 + " ist übrigens " + ((x1 + x2) / 2.0) + "!");
23 }
24 else if (x1 > 0 && x2 > 0)
25 {
26 System.out.println("Der Kehrwert von " + x1 + " ist ungefähr " + 1.0/x1 + "!");
27 }
28 else
29 {
30 System.out.println(x1 + x2);
31 }
32 }
33}