a
This commit is contained in:
20
src/de/javagames/Benutzereingabe.java
Normal file
20
src/de/javagames/Benutzereingabe.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package de.javagames;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Benutzereingabe {
|
||||||
|
public static void Eingabe(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.print("Bitte gib deinen Namen ein: ");
|
||||||
|
String name = scanner.nextLine();
|
||||||
|
|
||||||
|
System.out.print("Bitte gib dein Alter ein: ");
|
||||||
|
int alter = scanner.nextInt();
|
||||||
|
|
||||||
|
System.out.println("Bitte gib deine Groesse in meter ein: ");
|
||||||
|
float groesse = scanner.nextFloat();
|
||||||
|
|
||||||
|
System.out.println("Hallo, " + name + "! Du bist " + alter + " Jahre alt und " + groesse + "m groß.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,6 @@ package de.temprechner;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
TempRechner.fahrenheitEingabe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,25 @@
|
|||||||
package de.temprechner;
|
package de.temprechner;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class TempRechner {
|
public class TempRechner {
|
||||||
}
|
|
||||||
|
//Scanner
|
||||||
|
public static void fahrenheitEingabe() {
|
||||||
|
Scanner scan = new Scanner(System.in);
|
||||||
|
System.out.print("Bitte gib die Temperatur in Fahrenheit ein: ");
|
||||||
|
double fahrenheit = scan.nextDouble();
|
||||||
|
|
||||||
|
celsiusZuFahrenheit(fahrenheit);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Fahrenheit zu Celsius
|
||||||
|
public static double fahrenheitzuCelsius(double fahrenheit) {
|
||||||
|
return (fahrenheit - 32) * 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Celsius zu Fahrenheit
|
||||||
|
public static double celsiusZuFahrenheit(double celsius) {
|
||||||
|
return (celsius * 1.8) + 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user