From 4e85d3d65769851e52b03cdaf4df8c210e621246 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 31 Oct 2015 01:15:59 +0100 Subject: shortened filenames --- ws2015/EiP/blaetter/02/Arithmetik.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ws2015/EiP/blaetter/02/Arithmetik.java (limited to 'ws2015/EiP/blaetter/02/Arithmetik.java') 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 @@ +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); + } + } +} -- cgit v1.2.3