init
parent
af700a1bd9
commit
77f9fdb9d9
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Semesteraufgabe</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
public class CinF {
|
||||
private static final double UMRECHNUNGSFAKTOR = (double) 9 / 5;
|
||||
private double eingabe;
|
||||
|
||||
public CinF(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return ((this.eingabe * UMRECHNUNGSFAKTOR) + 32);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
public class CmInZoll {
|
||||
private static final double UMRECHNUNGSFAKTOR = 0.393701;
|
||||
private double eingabe;
|
||||
|
||||
public CmInZoll(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return (this.eingabe * UMRECHNUNGSFAKTOR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
public class FeetinMeter {
|
||||
private double eingabe;
|
||||
private static final double UMRECHNUNGSFAKTOR = 0.3048;
|
||||
|
||||
public FeetinMeter(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return (this.eingabe * UMRECHNUNGSFAKTOR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
public class FinC {
|
||||
|
||||
private double eingabe;
|
||||
private static final double UMRECHNUNGSFAKTOR = (double) 5 / 9;
|
||||
|
||||
public FinC(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return ((this.eingabe - 32) * UMRECHNUNGSFAKTOR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
public class InchesInCm {
|
||||
private double eingabe;
|
||||
private static final double UMRECHNUNGSFAKTOR = 2.54;
|
||||
|
||||
public InchesInCm(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return (this.eingabe * UMRECHNUNGSFAKTOR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
public class KGinLbs {
|
||||
private static final double UMRECHNUNGSFAKTOR = 2.20462;
|
||||
private double eingabe;
|
||||
|
||||
public KGinLbs(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return (this.eingabe * UMRECHNUNGSFAKTOR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
public class LbsInKg {
|
||||
private double eingabe;
|
||||
private static final double UMRECHNUNGSFAKTOR = 0.4536;
|
||||
|
||||
public LbsInKg(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return (this.eingabe * UMRECHNUNGSFAKTOR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
public class MinFt {
|
||||
private static final double UMRECHNUNGSFAKTOR = 3.28084;
|
||||
private double eingabe;
|
||||
|
||||
public MinFt(double eingabe) {
|
||||
this.eingabe = eingabe;
|
||||
}
|
||||
|
||||
public double getEingabe() {
|
||||
return eingabe;
|
||||
}
|
||||
|
||||
public double umrechnen() {
|
||||
return (this.eingabe * UMRECHNUNGSFAKTOR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
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");
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue