summaryrefslogtreecommitdiff
path: root/ws2015/eip/blaetter/02/Arithmetik.java
blob: 90335a40984e58a4fc5e3155e5f09be6a4946fae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Scanner;

class Arithmetik
{
    public static void main (String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Vorname: ");
        String vorname = scanner.nextLine();
        System.out.print("Nachname: ");
        String nachname = scanner.nextLine();
        System.out.print("x_1 = ");
        int x1 = scanner.nextInt();
        System.out.print("x_2 = ");
        int x2 = scanner.nextInt();
        
        System.out.print("Hallo " + vorname.substring(0,1) + ". " + nachname + "! ");

        if (x1 < x2)
            {
                System.out.println("Der Mittelwert von " + x1 + " und " + x2 + " ist übrigens " + ((x1 + x2) / 2.0) + "!");
            }
        else if (x1 > 0 && x2 > 0)
            {
                System.out.println("Der Kehrwert von " + x1 + " ist ungefähr " + 1.0/x1 + "!");
            }
        else
            {
                System.out.println(x1 + x2);
            }
    }
}