Noch mit alten Sachen Inklusive
							parent
							
								
									50086f4274
								
							
						
					
					
						commit
						d5c7ddb59d
					
				|  | @ -0,0 +1,52 @@ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Beschreiben Sie hier die Klasse Eingabe. | ||||||
|  |  *  | ||||||
|  |  * @author (Ihr Name)  | ||||||
|  |  * @version (eine Versionsnummer oder ein Datum) | ||||||
|  |  */ | ||||||
|  | import java.util.Scanner; | ||||||
|  | public class Eingabe | ||||||
|  | { | ||||||
|  |     public static void rechner() | ||||||
|  |     { | ||||||
|  |         Scanner sc = new Scanner(System.in); | ||||||
|  |         System.out.println("Erste Zahl eingeben: "); | ||||||
|  |         int eingabe = sc.nextInt(); | ||||||
|  |         System.out.println("Zweite Zahl eingeben: "); | ||||||
|  |         int eingabe2 = sc.nextInt(); | ||||||
|  |         System.out.println("Summe:"+ (eingabe + eingabe2)); | ||||||
|  |         System.out.println("Differenz:" + (eingabe - eingabe2)); | ||||||
|  |         System.out.println("Produkt:" + (eingabe * eingabe2)); | ||||||
|  |         if (eingabe2 == 0) | ||||||
|  |         { | ||||||
|  |             System.out.println("ERROR!"); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |              | ||||||
|  |         System.out.println("Quotient:" + (eingabe / eingabe2)); | ||||||
|  |         System.out.println("Rest:" + (eingabe % eingabe2)); | ||||||
|  |        } | ||||||
|  |     } | ||||||
|  |     public static void Mitternachtsformelrechner() | ||||||
|  |     { | ||||||
|  |         Scanner sc = new Scanner(System.in); | ||||||
|  |          | ||||||
|  |         System.out.println("Mitternachtsformelrechner"); | ||||||
|  |         System.out.println("Berechnet die Lösungen einer quadratischen Gleichung"); | ||||||
|  |         System.out.println("ax² + bx + c = 0"); | ||||||
|  |         System.out.println(); | ||||||
|  |         System.out.println("Bitte jetzt Parameter eingeben"); | ||||||
|  |         int a = sc.nextInt(); | ||||||
|  |         System.out.println("a: "); | ||||||
|  |         int b = sc.nextInt(); | ||||||
|  |         System.out.println("b: "); | ||||||
|  |         int c = sc.nextInt(); | ||||||
|  |         System.out.println("c: "); | ||||||
|  |         System.out.println("Die Lösungen der quadratischen Gleichung 1.0x² +-3.0x +.0 = sind: x1 = 2.0 und x2 = 1.0"); | ||||||
|  |          | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -0,0 +1,104 @@ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Beschreiben Sie hier die Klasse Methoden. | ||||||
|  |  *  | ||||||
|  |  * @author (Ihr Name)  | ||||||
|  |  * @version (eine Versionsnummer oder ein Datum) | ||||||
|  |  */ | ||||||
|  | public class Methoden | ||||||
|  | { | ||||||
|  |     public static int quadrat(int x) | ||||||
|  |     { | ||||||
|  |         int quadrat; | ||||||
|  |         quadrat = x*x; | ||||||
|  |         return quadrat; | ||||||
|  |          | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static int summe( int a, int b) | ||||||
|  |     { | ||||||
|  |         int ergebnis = a+b; | ||||||
|  |         return ergebnis;    | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static int differenz( int a, int b) | ||||||
|  |     { | ||||||
|  |         int ergebnis = a-b; | ||||||
|  |         return ergebnis; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static int produkt( int a, int b) | ||||||
|  |     { | ||||||
|  |         int ergebnis = a*b; | ||||||
|  |         return ergebnis; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static int quotient( int a, int b) | ||||||
|  |     { | ||||||
|  |         int ergebnis = a/b; | ||||||
|  |         return ergebnis; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static int term1() | ||||||
|  |     { | ||||||
|  |         return produkt(3, summe(2,5)); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static int term2( int x) | ||||||
|  |     { | ||||||
|  |         int zaehler = summe(produkt(4,x),8); | ||||||
|  |         int nenner = differenz(summe(8,9),produkt(3,5)); | ||||||
|  |         return quotient(zaehler,nenner); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Berechnet die Potenz a^b | ||||||
|  |      */ | ||||||
|  |     public static double potenz(double a, int b) | ||||||
|  |     { | ||||||
|  |         double zwischenergebnis = 1; | ||||||
|  |         for ( int i=0;i<b; i++) | ||||||
|  |         { | ||||||
|  |             zwischenergebnis = zwischenergebnis*a; | ||||||
|  |         } | ||||||
|  |         return zwischenergebnis;  | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static double max(double a, double b) | ||||||
|  |     { | ||||||
|  |         if (a>b) | ||||||
|  |         {return a;} | ||||||
|  |         else | ||||||
|  |         {return b;} | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static double min(double a, double b) | ||||||
|  |     { | ||||||
|  |         if (a<b) | ||||||
|  |         {return a;} | ||||||
|  |         else  | ||||||
|  |         {return b;} | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public static double abs(double a) | ||||||
|  |     { | ||||||
|  |         if (a<0) | ||||||
|  |         {return (a*(-1));} | ||||||
|  |         else  | ||||||
|  |         {return a;} | ||||||
|  |     }  | ||||||
|  |      | ||||||
|  |     public static int round(double a) | ||||||
|  |     { | ||||||
|  |         int vorkomma = (int)a; | ||||||
|  |         double nachkomma = a - ((int)a); | ||||||
|  |         if (nachkomma<0.5) | ||||||
|  |         { | ||||||
|  |             return vorkomma; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return vorkomma+1; | ||||||
|  |         } | ||||||
|  |     }    | ||||||
|  | } | ||||||
|  | @ -0,0 +1,44 @@ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Beschreiben Sie hier die Klasse Schleifen. | ||||||
|  |  *  | ||||||
|  |  * @author (Ihr Name)  | ||||||
|  |  * @version (eine Versionsnummer oder ein Datum) | ||||||
|  |  */ | ||||||
|  | import java.util.Scanner; | ||||||
|  | public class Schleifen | ||||||
|  | { | ||||||
|  |     public static void A1() | ||||||
|  |     { | ||||||
|  |         for(int i=0; i<30;i++) | ||||||
|  |         {  | ||||||
|  |             System.out.println("Nur Übung macht den Meister"); | ||||||
|  |         } | ||||||
|  |    } | ||||||
|  |    public static void A3a() | ||||||
|  |    { | ||||||
|  |        for(int i=1; i<21;i++) | ||||||
|  |        { | ||||||
|  |            System.out.println(Methoden.quadrat(i)); | ||||||
|  |        } | ||||||
|  |    } | ||||||
|  |    public static void A3b() | ||||||
|  |    { | ||||||
|  |        for(int i=0; i*i<500;i++) | ||||||
|  |        { | ||||||
|  |            System.out.println(i + "^2 = " + i*i); | ||||||
|  |        } | ||||||
|  |    } | ||||||
|  |    public static void A5() | ||||||
|  |    { | ||||||
|  |        Scanner sc = new Scanner(System.in); | ||||||
|  |        int zufallszahl = (int)(Math.random()*10+1); | ||||||
|  |        System.out.print("Erraten sie eine Zahl zwischen 1 und 10:"); | ||||||
|  |        int guess = sc.nextInt(); | ||||||
|  |        while(guess!=zufallszahl) | ||||||
|  |        { | ||||||
|  |            System.out.println("Leider falsch, versuchen sie es erneut!"); | ||||||
|  |        } | ||||||
|  |    } | ||||||
|  | } | ||||||
|  | 
 | ||||||
		Loading…
	
		Reference in New Issue