Initial sharing of project
commit
84a7f67f68
|
@ -0,0 +1,48 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Beschreiben Sie hier die Klasse AB_2_1.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class AB_2_1
|
||||
{
|
||||
public static void spiegeln(String text) {
|
||||
for(int i = text.length() - 1; i >= 0; i--) {
|
||||
System.out.print(text.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static void umrechnen(int time) {
|
||||
System.out.println(time + " Sekunden entsprechen:");
|
||||
|
||||
int sekunden = time % 60;
|
||||
time = (time - sekunden) / 60;
|
||||
|
||||
int minuten = time % 60;
|
||||
time = (time - minuten) / 60;
|
||||
|
||||
int stunden = time % 24;
|
||||
time = (time - stunden) / 24;
|
||||
|
||||
int tage = time % 365;
|
||||
time = (time - tage) / 365;
|
||||
|
||||
System.out.println(time + " Jahren,");
|
||||
System.out.println(tage + " Tagen,");
|
||||
System.out.println(stunden + " Stunden,");
|
||||
System.out.println(minuten + " Minuten und");
|
||||
System.out.println(sekunden + " Sekunden.");
|
||||
}
|
||||
|
||||
public static void einmaleins() {
|
||||
for (int a = 1; a <= 10; a++) {
|
||||
for (int b = 1; b <= 10; b++) {
|
||||
if (a*b < 10) System.out.print(" ");
|
||||
System.out.print(a*b + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
/**
|
||||
* Beschreiben Sie hier die Klasse AB_2_2.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class AB_2_2
|
||||
{
|
||||
public static int summe(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public static boolean istPrim(int a) {
|
||||
for(int n = 2; n < Math.sqrt(a); n++) {
|
||||
if (a % n == 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void primDoublette(int min) {
|
||||
if (min % 2 == 0) min++;
|
||||
while(!istPrim(min) || !istPrim(min+2)) {
|
||||
min += 2;
|
||||
}
|
||||
|
||||
System.out.println(min + " und " + (min+2) + " gefunden!");
|
||||
}
|
||||
|
||||
public static void tripel() {
|
||||
for(int a = 1; a < 100; a++) {
|
||||
for(int b = a; b < 100; b++) {
|
||||
for(int c = b; c < 100; c++) {
|
||||
if (a*a + b*b == c*c) {
|
||||
System.out.println(a + "^2 + " + b + "^2 = " + c + "^2");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
/**
|
||||
* Beschreiben Sie hier die Klasse AB_2_3.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class AB_2_3
|
||||
{
|
||||
public static void linear(float m, float c) {
|
||||
if (m == 0) {
|
||||
if (c == 0) System.out.println("Unendlich viele Nullstellen");
|
||||
else System.out.println("keine Nullstelle");
|
||||
return;
|
||||
}
|
||||
float x= - c / m;
|
||||
System.out.println("Nullstelle: ("+x+"|0)");
|
||||
}
|
||||
|
||||
public static void quadrat(float a, float b, float c) {
|
||||
float D = b*b - 4*a*c;
|
||||
if (D < 0) System.out.println("keine Nullstellen");
|
||||
double x1 = (-b + Math.sqrt(D))/(2*a);
|
||||
double x2 = (-b - Math.sqrt(D))/(2*a);
|
||||
if (D == 0) System.out.println("eine Nullstellen bei ("+x1+"|0)");
|
||||
else System.out.println("Nullstellen bei ("+x1+"|0) und ("+x2+"|0)");
|
||||
}
|
||||
|
||||
public static int glaeser(int n) {
|
||||
int sum = 0;
|
||||
for(int i=2; i<=n; i++) {
|
||||
sum += i*(i-1)/2;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
/**
|
||||
* Beschreiben Sie hier die Klasse AB_2_4.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class AB_2_4
|
||||
{
|
||||
public static boolean istSchaltjahr(int jahr) {
|
||||
if (jahr % 400 == 0) return true;
|
||||
if (jahr % 100 == 0) return false;
|
||||
if (jahr % 4 == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int tage(int monat, int jahr) {
|
||||
if (monat == 1) return 31;
|
||||
if (monat == 2) {
|
||||
if (istSchaltjahr(jahr)) return 29;
|
||||
return 28;
|
||||
}
|
||||
if (monat == 3) return 31;
|
||||
if (monat == 4) return 30;
|
||||
if (monat == 5) return 31;
|
||||
if (monat == 6) return 30;
|
||||
if (monat == 7) return 31;
|
||||
if (monat == 8) return 31;
|
||||
if (monat == 9) return 30;
|
||||
if (monat == 10) return 31;
|
||||
if (monat == 11) return 30;
|
||||
if (monat == 12) return 31;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String wochentag(int tag) {
|
||||
if (tag == 0) return "Montag";
|
||||
if (tag == 1) return "Dienstag";
|
||||
if (tag == 2) return "Mittwoch";
|
||||
if (tag == 3) return "Donnerstag";
|
||||
if (tag == 4) return "Freitag";
|
||||
if (tag == 5) return "Samstag";
|
||||
if (tag == 6) return "Sonntag";
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void ausgabe() {
|
||||
int wtag = 0;
|
||||
int sonntage = 0;
|
||||
|
||||
for(int jahr = 1900; jahr <= 2000; jahr ++) {
|
||||
for(int monat = 1; monat <= 12; monat ++) {
|
||||
for(int tag = 1; tag <= tage(monat,jahr); tag++) {
|
||||
if(wtag == 6) sonntage++;
|
||||
System.out.println(wochentag(wtag)+", "+tag+"."+monat+"."+jahr);
|
||||
wtag = (wtag + 1) % 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(sonntage+" Sonntage");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
------------------------------------------------------------------------
|
||||
Dies ist die README-Datei des Projekts. Hier sollten Sie Ihr Projekt
|
||||
beschreiben.
|
||||
Erzählen Sie dem Leser (jemand, der nichts über dieses Projekt weiss),
|
||||
alles, was er/sie wissen muss. Üblicherweise sollte der Kommentar
|
||||
zumindest die folgenden Angaben umfassen:
|
||||
------------------------------------------------------------------------
|
||||
|
||||
PROJEKTBEZEICHNUNG:
|
||||
PROJEKTZWECK:
|
||||
VERSION oder DATUM:
|
||||
WIE IST DAS PROJEKT ZU STARTEN:
|
||||
AUTOR(EN):
|
||||
BENUTZERHINWEISE:
|
|
@ -0,0 +1,53 @@
|
|||
#BlueJ package file
|
||||
editor.fx.0.height=528
|
||||
editor.fx.0.width=960
|
||||
editor.fx.0.x=0
|
||||
editor.fx.0.y=552
|
||||
objectbench.height=100
|
||||
objectbench.width=557
|
||||
package.divider.horizontal=0.6
|
||||
package.divider.vertical=0.7693965517241379
|
||||
package.editor.height=350
|
||||
package.editor.width=821
|
||||
package.editor.x=0
|
||||
package.editor.y=25
|
||||
package.frame.height=528
|
||||
package.frame.width=960
|
||||
package.numDependencies=0
|
||||
package.numTargets=4
|
||||
package.showExtends=true
|
||||
package.showUses=true
|
||||
project.charset=UTF-8
|
||||
readme.height=60
|
||||
readme.name=@README
|
||||
readme.width=48
|
||||
readme.x=10
|
||||
readme.y=10
|
||||
target1.height=70
|
||||
target1.name=AB_2_4
|
||||
target1.showInterface=false
|
||||
target1.type=ClassTarget
|
||||
target1.width=120
|
||||
target1.x=210
|
||||
target1.y=110
|
||||
target2.height=70
|
||||
target2.name=AB_2_3
|
||||
target2.showInterface=false
|
||||
target2.type=ClassTarget
|
||||
target2.width=120
|
||||
target2.x=210
|
||||
target2.y=10
|
||||
target3.height=70
|
||||
target3.name=AB_2_2
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.width=120
|
||||
target3.x=70
|
||||
target3.y=110
|
||||
target4.height=70
|
||||
target4.name=AB_2_1
|
||||
target4.showInterface=false
|
||||
target4.type=ClassTarget
|
||||
target4.width=120
|
||||
target4.x=70
|
||||
target4.y=10
|
Loading…
Reference in New Issue