spielekonsole spiel ausgeschrieben & TempRechner von Celsius zu Fahrenheit und Kelvin
This commit is contained in:
@@ -17,14 +17,14 @@ public class Spielekonsole {
|
||||
|
||||
public void spielnr() {
|
||||
System.out.print("Bitte wähle ein Spiel von 1-3 aus: ");
|
||||
int spielnr = scan.nextInt();
|
||||
if (spielnr == 1) {
|
||||
String spielnr = scan.next().toUpperCase();
|
||||
if (spielnr.equals("1") || spielnr.equals("EINS")) {
|
||||
System.out.println("Du hast Spiel 1 ausgewählt!");
|
||||
}
|
||||
else if (spielnr == 2) {
|
||||
else if (spielnr.equals("2") || spielnr.equals("ZWEI")) {
|
||||
System.out.println("Du hast Spiel 2 ausgewählt!");
|
||||
}
|
||||
else if (spielnr == 3) {
|
||||
else if (spielnr.equals("3") || spielnr.equals("DREI")) {
|
||||
System.out.println("Du hast Spiel 3 ausgewählt!");
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2,6 +2,6 @@ package de.temprechner;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
TempRechner.fahrenheitEingabe();
|
||||
TempRechner.rechner();
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,28 @@ import java.util.Scanner;
|
||||
public class TempRechner {
|
||||
|
||||
//Scanner
|
||||
public static void fahrenheitEingabe() {
|
||||
public static void rechner() {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
System.out.print("Bitte gib die Temperatur in Fahrenheit ein: ");
|
||||
double fahrenheit = scan.nextDouble();
|
||||
System.out.println("Was willst du umrechnen?");
|
||||
System.out.println("1: Celsius zu Fahrenheit");
|
||||
System.out.println("2: Celsius zu Kelvin");
|
||||
System.out.print("Deine Wahl = ");
|
||||
|
||||
celsiusZuFahrenheit(fahrenheit);
|
||||
}
|
||||
int auswahl = scan.nextInt();
|
||||
|
||||
//Fahrenheit zu Celsius
|
||||
public static double fahrenheitzuCelsius(double fahrenheit) {
|
||||
return (fahrenheit - 32) * 1.8;
|
||||
}
|
||||
System.out.print("Gib die Temperatur in Celsius ein: ");
|
||||
double celsius = scan.nextDouble();
|
||||
|
||||
//Celsius zu Fahrenheit
|
||||
public static double celsiusZuFahrenheit(double celsius) {
|
||||
return (celsius * 1.8) + 32;
|
||||
if (auswahl == 1) {
|
||||
double fahrenheit = (celsius * 1.8) + 32;
|
||||
System.out.println(celsius + " °C entsprechen " + fahrenheit + " °F.");
|
||||
} else if (auswahl == 2) {
|
||||
double kelvin = celsius + 273.15;
|
||||
System.out.println(celsius + " °C entsprechen " + kelvin + " K.");
|
||||
} else {
|
||||
System.out.println("Ungültige Auswahl! Bitte starte das Programm erneut.");
|
||||
}
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user