Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch.hslu.demo;
- import java.util.Scanner;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- /**
- * Demo-Applikation
- */
- public final class DemoApp {
- private static final Logger LOG = LogManager.getLogger(DemoApp.class);
- /**
- * Privater Konstruktor.
- */
- private DemoApp() {
- }
- /**
- * Main-Methode.
- * @param args Startargumente.
- */
- public static void main(String[] args) {
- String input;
- Scanner scanner = new Scanner(System.in);
- do {
- System.out.println("Bitte Zahl eingeben ('exit' zum Beenden): ");
- input = scanner.next();
- float value;
- try {
- value = Float.valueOf(input);
- System.out.println(Temperatur.createFromCelsius(value).getCelsius());
- } catch (NumberFormatException e) {
- if(!input.equals("exit")) {
- LOG.error("Bitte gebe eine gültige Zahl ein.");
- }
- } catch (IllegalArgumentException e) {
- LOG.error(e.getMessage());
- }
- } while (!input.equals("exit"));
- LOG.info("Programm beendet.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement