108 lines
4.2 KiB
Java
108 lines
4.2 KiB
Java
|
import java.util.*;
|
||
|
|
||
|
public class Umrechnung {
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
|
||
|
anzeige(); // ruft die Informationen auf
|
||
|
Scanner scanner = new Scanner(System.in);
|
||
|
while (true) {
|
||
|
try {
|
||
|
// Umrechnung:
|
||
|
System.out.println("Eingabe: ");
|
||
|
String eingabe = scanner.nextLine();
|
||
|
String[] input = eingabe.split(" ");
|
||
|
|
||
|
// Pfund(lbs)-->Kilogramm(kg)
|
||
|
if (input[0].equalsIgnoreCase("lbsinkg")) {
|
||
|
LbsInKg u1 = new LbsInKg(Double.parseDouble(input[1]));
|
||
|
System.out.println((u1.getEingabe() + "lbs sind " + u1.umrechnen() + "kg"));
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Zoll(inch)--> Zentimeter(cm)
|
||
|
else if (input[0].equalsIgnoreCase("inchesincm")) {
|
||
|
InchesInCm u2 = new InchesInCm(Double.parseDouble(input[1]));
|
||
|
System.out.println(u2.getEingabe() + " inches sind " + u2.umrechnen() + "cm");
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Grad Fahrenheit(Fahrenheit)-->Grad Celsius(Celsius)
|
||
|
else if (input[0].equalsIgnoreCase("finc")) {
|
||
|
FinC u3 = new FinC(Double.parseDouble(input[1]));
|
||
|
System.out.println(u3.getEingabe() + " ° F sind " + u3.umrechnen() + "° C");
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Fuß(ft)-->Meter(m)
|
||
|
else if (input[0].equalsIgnoreCase("FtInM")) {
|
||
|
FeetinMeter u4 = new FeetinMeter(Double.parseDouble(input[1]));
|
||
|
System.out.println(u4.getEingabe() + " ft sind " + u4.umrechnen() + "m");
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Kilogramm(kg)-->Pfund(lbs)
|
||
|
else if (input[0].equalsIgnoreCase("KgInLbs")) {
|
||
|
KGinLbs u5 = new KGinLbs(Double.parseDouble(input[1]));
|
||
|
System.out.println(u5.getEingabe() + " kg sind " + u5.umrechnen() + "lbs");
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Zentimeter(cm)--> Zoll(inch)
|
||
|
else if (input[0].equalsIgnoreCase("CmInInches")) {
|
||
|
CmInZoll u6 = new CmInZoll(Double.parseDouble(input[1]));
|
||
|
System.out.println(u6.getEingabe() + " cm sind " + u6.umrechnen() + "inches");
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Meter(m)-->Fuß(ft)
|
||
|
else if (input[0].equalsIgnoreCase("MinFt")) {
|
||
|
MinFt u7 = new MinFt(Double.parseDouble(input[1]));
|
||
|
System.out.println(u7.getEingabe() + " m sind " + u7.umrechnen() + "ft");
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Grad Celsius(Celsius)-->Grad Fahrenheit(Fahrenheit)
|
||
|
else if (input[0].equalsIgnoreCase("CinF")) {
|
||
|
CinF u8 = new CinF(Double.parseDouble(input[1]));
|
||
|
System.out.println(u8.getEingabe() + " ° C sind " + u8.umrechnen() + "° F");
|
||
|
System.out.println("----------------------------");
|
||
|
}
|
||
|
|
||
|
// Beendet das Programm
|
||
|
else if (input[0].equalsIgnoreCase("ende")) {
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
// ruft Möglichen Befehle auf
|
||
|
else if (input[0].equalsIgnoreCase("help")) {
|
||
|
System.out.println("Liste möglicher Befehle:");
|
||
|
System.out.println(
|
||
|
" -help \n -ende \n \n -LbsInKg <lbs>\n -InchesInCm <inches>\n -FtInM <Feet>\n -FinC <Fahrenheit>\n \n -KgInLbs <kg>\n -CmInZoll <cm>\n -MinFt <m>\n -CinF <Celsius>\n \n");
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
System.out.println("Befehl konnte nicht verarbeitet werden. Benutzen sie \"help\"");
|
||
|
}
|
||
|
} catch (Exception e) {
|
||
|
System.out.println("Achten sie auf das richtige Format. Benutzen sie \"help\"");
|
||
|
}
|
||
|
}
|
||
|
scanner.close();
|
||
|
|
||
|
}
|
||
|
|
||
|
// Information
|
||
|
public static void anzeige() {
|
||
|
System.out.println("Umrechnungsprogramm");
|
||
|
System.out.println("Diese Umrechnungen bietet das Programm an: ");
|
||
|
System.out.println(
|
||
|
" -LbsInKg(Pfund(lbs)-->Kilogramm(kg)) und KgInLbs(Kilogramm(kg)-->Pfund(lbs)) \n -InchesInCm(Zoll(inch)--> Zentimeter(cm)) und -CmInInches (Zentimeter(cm)--> Zoll(inch)) \n -FtinM (Fuß(ft)-->Meter(m)) und MinFt (Meter(m)-->Fuß(ft))\n -FinC(Grad Fahrenheit(Fahrenheit)-->Grad Celsius(Celsius)) und -CinF (Grad Celsius(Celsius)-->Grad Fahrenheit(Fahrenheit)) ");
|
||
|
System.out.println("Liste möglicher Befehle:");
|
||
|
System.out.println(
|
||
|
" -help \n -ende \n \n -LbsInKg <lbs>\n -InchesInCm <inches>\n -FtInM <Feet>\n -FinC <Fahrenheit>\n \n -KgInLbs <kg>\n -CmInInches <cm>\n -MinFt <m>\n -CinF <Celsius>\n \n");
|
||
|
|
||
|
}
|
||
|
}
|