u08 - u10

This commit is contained in:
Luca Conte 2022-10-27 19:41:19 +02:00
parent d90e8e22a1
commit aa01aad344
5 changed files with 38 additions and 0 deletions

BIN
u08/Wurzel.class Normal file

Binary file not shown.

11
u08/Wurzel.java Normal file
View File

@ -0,0 +1,11 @@
/**
Klasse zum Wurzel Ziehen
*/
public class Wurzel {
/**
Zieht die n-te Wurzel einer Zahl
*/
public static double zahlHoch1Durchn(double zahl, int wurzelexponent) {
return Math.pow(zahl, 1.0 / wurzelexponent);
}
}

11
u09/Cent.java Normal file
View File

@ -0,0 +1,11 @@
/**
Klasse zum errechnen der Cent-Stuecke
*/
public class Cent {
/**
Gibt aus, wie viele 20-Cent stuecke optimal in einem Geldbetrag enthalten sind
*/
public static int zaehle20CentStuecke(int cent) {
return cent % 100 / 20;
}
}

BIN
u10/Swap.class Normal file

Binary file not shown.

16
u10/Swap.java Normal file
View File

@ -0,0 +1,16 @@
import java.awt.*;
public class Swap {
public static void main(String[] args) {
Point p1= new Point(5, 2);
Point p2= new Point(-3, 6);
swapPoints(p1, p2);
System.out.println("p1: ("+p1.x+", "+p1.y+")");
System.out.println("p2: ("+p2.x+", "+p2.y+")");
}
public static void swapPoints(Point p1, Point p2) {
Point ptmp = new Point(p1.x, p1.y);
p1.setLocation(p2.x, p2.y);
p2.setLocation(ptmp.x, ptmp.y);
}
}