InfoRepository/Methoden.java

126 lines
2.1 KiB
Java

public class Methoden
{
public static double quadrat(double x) {
double quadrat;
quadrat = x * x;
return quadrat;
}
public static void test()
{
System.out.println(quadrat(3));
}
public static int summe(int a, int b){
int summe = a + b;
return summe;
}
public static int differenz(int c, int d){
int differenz = c - d;
return differenz;
}
public static int produkt(int e, int f){
int produkt = e * f;
return produkt;
}
public static int quotient(int g, int h){
int quotient = g / h;
return quotient;
}
public static int term(int x){
System.out.println(summe(produkt(3, 2), produkt(3, 5)));
int ergebnis = quotient(summe(produkt(4, x), 8), differenz(summe(8, 9), produkt(3, 5)));
return ergebnis;
}
/**
* Berechnet die Potenz a^b
*/
public static double potenz(double j, double k){
double E = 1;
for (int i = 0; i < k; i++){
E = E* j;
}
return E;
}
public static int max(int a, int b){
if( a < b)
return b;
else{ return a;
}
}
public static int min(int a, int b){
if( a > b)
return b;
else{ return a;
}
}
public static int abs(int a){
if( a < 0)
return produkt(a, -1);
else{
return a;
}
}
public static int round(double a){
int vorkomma = (int) a;
double nachkomma = a - vorkomma;
if(nachkomma >= 0.5)
return (int) a + 1;
else{
return (int) a;
}
}
public static boolean istGroß(double a){
if( a > 1000)
return true;
else{
return false;
}
}
public static boolean istBetragsmaesigGroß(double a){
if(abs((int)a) > 1000)
return true;
else{
return false;
}
}
public static boolean istGerade(int a){
}
}