test
commit
121b0acb7c
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>übung2</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,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,14 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
|
@ -0,0 +1,29 @@
|
|||
package übung2;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Programmieruebung {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
String[] fragen = {"was ist 3*3 , was sind 8+3"};
|
||||
int[] antworten = { 9, 11};
|
||||
|
||||
int count = 0;
|
||||
|
||||
while(count < fragen.length) {
|
||||
System.out.println(fragen[count]);
|
||||
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int eingabeUser= scan.nextInt();
|
||||
|
||||
if(eingabeUser== antworten[count]) {
|
||||
System.out.println("Richtig");
|
||||
count++;
|
||||
}else {
|
||||
System.out.println("Falsch");
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package übung2;
|
||||
import java.util.Scanner;
|
||||
public class fahrenheit {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
Scanner scann = new Scanner(System.in);
|
||||
System.out.println("(1)F->C oder (2)C->F");
|
||||
int menue = scann.nextInt();
|
||||
Object s = null;
|
||||
if (menue==1) {
|
||||
System.out.println("Bitte geben Sie die Temperatur in Fahrenheit ein");
|
||||
double fahrenheit = scann.nextDouble();
|
||||
double celsius = (fahrenheit-32) *5/9;
|
||||
|
||||
System.out.println("sind"+celsius+"Grad Celsius");
|
||||
}
|
||||
else if (menue==2) {
|
||||
System.out.println("Bitte geben Sie die Temperatur in Celsius ein");
|
||||
double celsius = scann.nextDouble();
|
||||
double fahrenheit = celsius*1.8 + 32;
|
||||
|
||||
System.out.println("sind"+fahrenheit+"Grad Fahrenheit");
|
||||
}else {
|
||||
System.out.println("Sie haben die falsche Eingabe getätigt.");
|
||||
|
||||
//Object s1 = null;
|
||||
do {
|
||||
System.out.println("Nochmal? j/n");
|
||||
Object s11;
|
||||
|
||||
Scanner sann = null;
|
||||
s11 = sann.nextLine();
|
||||
}while(!s.equals('j') && !s.equals ('n'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
package übung2;
|
||||
|
||||
import java.util.Scanner; //import scanner from java library
|
||||
|
||||
public class romische_uebung_2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String s;
|
||||
Scanner scann = new Scanner(System.in);
|
||||
do{//give the scanner and give it a name
|
||||
System.out.println("(1)Dezimahl->Römisch oder (2)Römisch->Dezimal"); //print (1)D->R or (2)R->D
|
||||
|
||||
int wahl = scann.nextInt(); // Scanner scann saves input of the user in variable wahl
|
||||
|
||||
|
||||
|
||||
if (wahl == 1) {
|
||||
//controls if users input is 1 , print "text" and start for loop
|
||||
System.out.println("Geben Sie eine Dezimalzahl ein");
|
||||
int dezimal = scann.nextInt(); //Scanner scann saves input of the user in variable dezimal
|
||||
for (int i = 0; i < dezimal; i = i + 1) { //start condition is i=o , endcondition is i <dezimal
|
||||
if (dezimal >= 400) { //starts counting from 1 to users input , time of loops
|
||||
dezimal = dezimal - 400; //if users input is ...,replace dezimal input and print...
|
||||
System.out.print("CD");
|
||||
|
||||
} else if (dezimal >= 900) { // else other users input
|
||||
dezimal = dezimal - 900;
|
||||
System.out.print("CM");
|
||||
|
||||
} else if (dezimal >= 500) {
|
||||
dezimal = dezimal - 500;
|
||||
System.out.print("D");
|
||||
|
||||
} else if (dezimal >= 1000) {
|
||||
dezimal = dezimal - 1000;
|
||||
System.out.print("M");
|
||||
|
||||
} else if (dezimal >= 100) {
|
||||
dezimal = dezimal - 100;
|
||||
System.out.print("C");
|
||||
|
||||
} else if (dezimal >= 90) {
|
||||
dezimal = dezimal - 90;
|
||||
System.out.print("XC");
|
||||
|
||||
} else if (dezimal >= 50) {
|
||||
dezimal = dezimal - 50;
|
||||
System.out.print("L");
|
||||
|
||||
} else if (dezimal >= 40) {
|
||||
dezimal = dezimal - 40;
|
||||
System.out.print("XL");
|
||||
|
||||
} else if (dezimal >= 10) {
|
||||
dezimal = dezimal - 10;
|
||||
System.out.print("X");
|
||||
|
||||
} else if (dezimal >= 9) {
|
||||
dezimal = dezimal - 9;
|
||||
System.out.print("IX");
|
||||
|
||||
|
||||
} else if (dezimal >= 5) {
|
||||
dezimal = dezimal - 5;
|
||||
System.out.print("V");
|
||||
|
||||
} else if (dezimal >= 4) {
|
||||
dezimal = dezimal - 4;
|
||||
System.out.print("IV");
|
||||
|
||||
} else if (dezimal >= 1) {
|
||||
dezimal = dezimal - 1;
|
||||
System.out.print("I");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (wahl == 2) {
|
||||
////when users input 2 , print "text" and start second part of program
|
||||
System.out.println("Geben Sie die römische Zahl ein");
|
||||
String eingabe = scann.next(); //Scanner scann saves input of the user in variable eingabe
|
||||
|
||||
int speicher = 0; //variable speicher starts at zero
|
||||
for (int i = 0; i <= eingabe.length() - 1; i++) {
|
||||
//start condition is i=0 , end condition is i < eingabe
|
||||
|
||||
eingabe = eingabe.replace("IV", "4"); //users input is replaced with "... "
|
||||
eingabe = eingabe.replace("IX", "9");
|
||||
eingabe = eingabe.replace("XC", "Q");
|
||||
eingabe = eingabe.replace("CM", "t");
|
||||
eingabe = eingabe.replace("XL", "p");
|
||||
|
||||
for (i = 0; i < eingabe.length(); i++) {
|
||||
|
||||
if (eingabe.charAt(i) == 'M') {
|
||||
speicher += 1000;
|
||||
//look in loop for users input and adds certain number to variale speicher
|
||||
} else if (eingabe.charAt(i) == 'Q') {
|
||||
// if not users input "M" then look for other romic in loop
|
||||
speicher = speicher + 900;
|
||||
} else if (eingabe.charAt(i) == 'C') {
|
||||
speicher = speicher + 100;
|
||||
} else if (eingabe.charAt(i) == 't') {
|
||||
speicher = speicher + 90;
|
||||
} else if (eingabe.charAt(i) == 'L') {
|
||||
speicher = speicher + 50;
|
||||
} else if (eingabe.charAt(i) == 'X') {
|
||||
speicher = speicher + 10;
|
||||
} else if (eingabe.charAt(i) == 'V') {
|
||||
speicher = speicher + 5;
|
||||
|
||||
} else if (eingabe.charAt(i) == '9') {
|
||||
speicher = speicher + 9;
|
||||
} else if (eingabe.charAt(i) == '4') {
|
||||
speicher = speicher + 4;
|
||||
} else if (eingabe.charAt(i) == 'I') {
|
||||
speicher = speicher + 1;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}System.out.println(speicher); // prints users input saved in variable speicher
|
||||
|
||||
|
||||
}} else {
|
||||
System.out.println("Sie haben die falsche Eingabe getätigt");
|
||||
|
||||
}
|
||||
System.out.println("\n" +"Nochmal? j/n");
|
||||
do {
|
||||
|
||||
s=scann.nextLine(); // user can give input in control
|
||||
}while(!s.equals("j")&& !s.equals("n")) ; }
|
||||
//user can only write "j" or "n" under print "text" or program wont work
|
||||
while (s.equals("j"));
|
||||
// if "j" then whole program starts over
|
||||
//if "n" then print "program terminated"‚
|
||||
System.out.println("Programm wurde beendet");
|
||||
|
||||
|
||||
|
||||
|
||||
//}
|
||||
|
||||
|
||||
}}
|
||||
//}
|
||||
//}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package übung2;
|
||||
|
||||
|
||||
|
||||
public class udemyUebung {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
double wert =taschenrechner(6.354, 3.547, '*');
|
||||
System.out.println(wert);
|
||||
|
||||
}
|
||||
|
||||
public static double taschenrechner(double zahl1, double zahl2, char operator) {
|
||||
double summe;
|
||||
if(operator == '*') {
|
||||
summe = zahl1 * zahl2;
|
||||
}else if(operator == '+') {
|
||||
summe = zahl1 + zahl2;
|
||||
}else {
|
||||
summe = zahl1 - zahl2;
|
||||
}
|
||||
|
||||
|
||||
return summe;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue