This commit is contained in:
Mykola Fesenko
2025-07-29 09:05:07 +02:00
parent ce8e5eb3fe
commit 721931ac60
68 changed files with 608 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,63 @@
public class Auto {
// Anfang Attribute
private String Farbe;
private int leistung;
private int anzTueren;
private String Hersteller;
// Ende Attribute
public Auto(String Farbe, int leistung, int anzTueren, String Hersteller) {
this.Farbe = Farbe;
this.leistung = leistung;
this.anzTueren = anzTueren;
this.Hersteller = Hersteller;
}
// Anfang Methoden
public String getFarbe() {
return Farbe;
}
public void setFarbe(String FarbeNeu) {
Farbe = FarbeNeu;
}
public int getLeistung() {
return leistung;
}
public void setLeistung(int leistungNeu) {
leistung = leistungNeu;
}
public int getAnzTueren() {
return anzTueren;
}
public void setAnzTueren(int anzTuerenNeu) {
anzTueren = anzTuerenNeu;
}
public String getHersteller() {
return Hersteller;
}
public void setHersteller(String HerstellerNeu) {
Hersteller = HerstellerNeu;
}
public void tuning(int leistungNeu) {
double leistungMax = leistung * 0.2;
if(leistungNeu < leistungMax){
leistung += leistungNeu;
System.out.println("Das Tuning wurde durchgeführt, das Auto hat jetzt " + leistung + "PS");
}
else{
System.out.println("Das Tuning übersteigt die Möglichkeiten des Fahrzeugs. Es können maximal " + leistungMax + "PS hinzukommen!");
}
}
// Ende Methoden
} // end of Auto

View File

@@ -0,0 +1,36 @@
[Files]
File0=Auto.java
File1=AutoAufruf.java
[Box: - Auto]
X=20
Y=40
MinVis=0
ShowParameter=4
SortOrder=0
ShowIcons=1
[Box: - AutoAufruf]
X=647
Y=244
MinVis=0
ShowParameter=4
SortOrder=0
ShowIcons=1
[Diagram]
comments=0
OffsetX=0
OffsetY=0
Visibility=0
ShowParameter=4
SortOrder=0
ShowIcons=1
ShowConnections=0
Fontname=Segoe UI
Fontsize=12
ShowObjectDiagram=0
[Interactive]
I0=

View File

@@ -0,0 +1,9 @@
public class AutoAufruf {
public static void main(String args[]){
Auto car = new Auto("Rot", 140, 5, "GHSE");
System.out.println("Das Auto von " + car.getHersteller() + " ist " + car.getFarbe() + ", hat " + car.getLeistung() + "PS und " + car.getAnzTueren() + " Türen.");
car.tuning(40);
car.tuning(25);
}
} // end of AutoAufruf

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,38 @@
import java.util.Arrays;
import java.util.Scanner;
public class Noten{
public static void main(String args[]){
double[] noten = new double[6];
double summe = 0;
// Noten eingeben und prüfen
Scanner eingabe = new Scanner(System.in);
for (int i = 0; i < noten.length; i++) {
System.out.print("Bitte Note Nr. " + (i+1) + " eingeben: ");
double note = eingabe.nextDouble();
if(note >= 1 && note <= 6){
noten[i] = note;
}
else{
System.out.println("Die Note muss zwischen 1 und 6 liegen!");
i--;
}
} // end of for
// Noten sortiert ausgeben
Arrays.sort(noten);
for (int i = 0; i < noten.length; i++) {
System.out.println("Note Nr. " + (i+1) + " lautet " + noten[i]);
summe += noten[i];
} // end of for
// Durchschnitt aus Summe der Noten und Array-Größe berechnen
double durchschnitt = summe / noten.length;
System.out.println("Der Durchschnitt ist " + durchschnitt);
}
}

Binary file not shown.

View File

@@ -0,0 +1,36 @@
public class BMI{
public static void main(String args[]){
double gewicht = 120;
double groesse = 1.8;
double bmi = gewicht / (groesse * groesse);
System.out.println("Dein BMI bei einer Größe von " + groesse + "m") ;
System.out.println("und einem Gewicht von " + gewicht + "kg");
System.out.println("beträgt " + bmi);
if (bmi < 16) {
System.out.println("Starkes Untergewicht");
}
else if(bmi < 17) {
System.out.println("Mäßiges Untergewicht");
}
else if(bmi < 18.5) {
System.out.println("Leichtes Untergewicht");
}
else if (bmi < 25) {
System.out.println("Normalgewicht");
}
else if (bmi < 30) {
System.out.println("Übergewicht");
}
else if (bmi < 35) {
System.out.println("Adipositas I");
}
else if (bmi < 40) {
System.out.println("Adipositas II");
}
else {
System.out.println("Adipositas III");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,14 @@
public class BruttoNetto {
public static void main(String args[]){
double brutto = 50.0;
double netto = brutto / 1.19;
double ust = brutto - netto;
System.out.println("Netto: " + netto);
System.out.println("USt: " + ust);
System.out.println("USt-Aktion: " + (ust / brutto));
// netto = 100% = brutto / (1 + 19/100)
// brutto = 119% = netto * (1 + 19/100)
}
}

Binary file not shown.

View File

@@ -0,0 +1,16 @@
import java.util.Scanner;
public class Eingabe {
public static void main(String args[]){
Scanner eingabe = new Scanner(System.in);
System.out.print("Bitte eine ganze Zahl eingeben: ");
if(eingabe.hasNextInt()){
int zahl = eingabe.nextInt();
System.out.println("Das Quadrat von " + zahl + " ist " + (zahl * zahl));
}
else {
System.out.println("Bitte nur ganze Zahlen eingeben!!");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,24 @@
import java.util.Scanner;
public class J04A1 {
public static void main(String args[]){
char firstChar = 'N';
switch (firstChar) {
case 'j':
System.out.println("ja");
break;
case 'J':
System.out.println("Ja");
break;
case 'n':
System.out.println("nein");
break;
case 'N':
System.out.println("Nein");
break;
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,36 @@
import java.util.Arrays;
public class J05A2 {
public static void main(String args[]){
int zahlen[] = {13, 9, 67, 42, 101, 99, 97, 112, 83, 5, 78};
// a)
for (int i = 0; i < zahlen.length; i++) {
System.out.println("Zahl Nr. " + (i+1) + " lautet " + zahlen[i]);
}
for (int zahl: zahlen ) {
System.out.println(zahl);
}
// b)
for (int i = 0; i < zahlen.length; i++) {
if (i < zahlen.length - 1) {
System.out.print(zahlen[i] + " - ");
} else {
System.out.println(zahlen[i]);
}
}
// c)
Arrays.sort(zahlen);
for (int zahl: zahlen ) {
System.out.println(zahl);
}
System.out.println("Kleinstes Element: " + zahlen[0]);
System.out.println("Größtes Element: " + zahlen[zahlen.length - 1]);
}
}

Binary file not shown.

View File

@@ -0,0 +1,13 @@
public class Kraftstoffverbrauch {
public static void main(String args[]){
double gefahreneKm = 437;
double verbrauchterKraftstoff = 28.9;
double verbrauch100Km = (verbrauchterKraftstoff / gefahreneKm) * 100;
System.out.println("Gefahrene KM: " + gefahreneKm);
System.out.println("Verbrauchter Kraftstoff: " + verbrauchterKraftstoff +" Liter");
System.out.println("Verbrauch je 100km: " + verbrauch100Km + " Liter je 100Km");
}
}

Binary file not shown.

View File

@@ -0,0 +1,60 @@
import java.util.Arrays;
import java.util.Scanner;
public class Lottozahlen {
public static void main(String args[]){
int lottozahlen[] = {17, 9, 39, 23, 41, 6};
//Scanner eingabe = new Scanner(System.in);
/*
int lottozahlen[] = new int[6];
lottozahlen[0] = eingabe.nextInt();
lottozahlen[1] = eingabe.nextInt();
lottozahlen[2] = eingabe.nextInt();
lottozahlen[3] = eingabe.nextInt();
lottozahlen[4] = eingabe.nextInt();
lottozahlen[5] = eingabe.nextInt();
*/
System.out.println("Die heutigen Lottozahlen sind " + lottozahlen);
System.out.println("Es sind " + lottozahlen.length + " Lottozahlen gezogen worden.");
System.out.println("Die erste Lottozahl lautet: " + lottozahlen[0]);
System.out.println("Die zweite Lottozahl lautet: " + lottozahlen[1]);
System.out.println("Die dritte Lottozahl lautet: " + lottozahlen[2]);
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
System.out.println("Die fünfte Lottozahl lautet: " + lottozahlen[4]);
System.out.println("Die sechste Lottozahl lautet: " + lottozahlen[5]);
System.out.println("- - - - - - - - - - - - - - - - - - -");
//lottozahlen[3] = 32;
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
System.out.println("- - - - - - - - - - - - - - - - - - -");
for (int i = 0; i < lottozahlen.length; i++) {
System.out.println("Lottozahl Nr. " + (i + 1) + " lautet " + lottozahlen[i]);
}
System.out.println("- - - - - - - - - - - - - - - - - - -");
for (int zahl: lottozahlen) {
System.out.println("Die aktuelle Lottozahl lautet: " + zahl);
}
System.out.println("- - - - - - - - - - - - - - - - - - -");
Arrays.sort(lottozahlen);
System.out.println("Die erste Lottozahl lautet: " + lottozahlen[0]);
System.out.println("Die zweite Lottozahl lautet: " + lottozahlen[1]);
System.out.println("Die dritte Lottozahl lautet: " + lottozahlen[2]);
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
System.out.println("Die fünfte Lottozahl lautet: " + lottozahlen[4]);
System.out.println("Die sechste Lottozahl lautet: " + lottozahlen[5]);
System.out.println("- - - - - - - - - - - - - - - - - - -");
System.out.println("Die heutigen Lottozahlen sind: " + Arrays.toString(lottozahlen));
}
}

Binary file not shown.

View File

@@ -0,0 +1,5 @@
public class MeinErstesProgramm{
public static void main(String args[]){
System.out.println("Hallo Welt!");
}
}

Binary file not shown.

View File

@@ -0,0 +1,32 @@
public class Monat {
public static void main(String args[]){
int monat = 7;
switch (monat) {
case 1:
System.out.println("Januar");
break;
case 2:
System.out.println("Februar");
break;
case 3:
System.out.println("März");
break;
case 4:
System.out.println("April");
break;
case 5:
System.out.println("Mai");
break;
case 6:
System.out.println("Juni");
break;
default:
System.out.println("Du hast keine gültige Monatszahl eingegeben!");
} // end of switch
}
}

View File

@@ -0,0 +1,33 @@
public class Monat {
public static void main(String args[]){
int monat = 7;
switch (monat) {
case 1:
System.out.println("Januar");
break;
case 2:
System.out.println("Februar");
break;
case 3:
System.out.println("März");
break;
case 4:
System.out.println("April");
break;
case 5:
System.out.println("Mai");
break;
case 6:
System.out.println("Juni");
break;
default:
System.out.println("Du hast keine gültige Monatszahl eingegeben!");
} // end of switch
}
}

Binary file not shown.

View File

@@ -0,0 +1,10 @@
public class ProgExpr {
public static void main (String args[]) {
int guthaben = 1000;
System.out.println("Guthaben = " + guthaben);
int einzahlung = 500;
System.out.println("Einzahlung = " + einzahlung);
guthaben = guthaben + einzahlung;
System.out.println("Guthaben = " + guthaben);
}
}

Binary file not shown.

View File

@@ -0,0 +1,13 @@
public class ProgFor {
public static void main (String args[]) {
int guthaben = 1000;
int einzahlung = 500;
System.out.println("Guthaben = " + guthaben);
System.out.println("Einzahlung = " + einzahlung + " pro Monat");
for ( int monat=1; monat<=6; monat = monat + 1 ) {
guthaben = guthaben + einzahlung;
System.out.println(monat + ". Monat:");
System.out.println(" Guthaben = " + guthaben);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,9 @@
public class ProgIf {
public static void main (String args[]) {
int guthaben = 50000;
System.out.println("Guthaben = " + guthaben);
if ( guthaben >= 1000000 ) {
System.out.println("Gratuliere, Du bist Millionaer!");
}
}
}

View File

@@ -0,0 +1,9 @@
public class ProgIf {
public static void main (String args[]) {
int guthaben = 50000;
System.out.println("Guthaben = " + guthaben);
if ( guthaben >= 1000000 ) {
System.out.println("Gratuliere, Du bist Millionaer!");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,14 @@
public class ProgWhile {
public static void main (String args[]) {
int guthaben = 1000;
int sparziel = 8000;
int einzahlung = 600;
System.out.println ("Guthaben = " + guthaben);
System.out.println ("Sparziel = " + sparziel);
while ( guthaben < sparziel ) {
guthaben = guthaben + einzahlung;
System.out.println ("neues Guthaben = " + guthaben);
}
System.out.println( "Sparziel erreicht.");
}
}

Binary file not shown.

View File

@@ -0,0 +1,8 @@
public class Quadratzahlen{
public static void main(String args[]) {
for (int i = 1; i <= 20 ; i++ ) {
int quadrat = i * i;
System.out.println("Die Quadratzahl von " + i + " lautet " + quadrat);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,11 @@
public class Sparbuch{
public static void main(String args[]){
double guthaben = 1000;
double zinssatz = 1.5/100;
for (int jahr = 1; jahr <= 25 ; jahr++ ) {
guthaben = guthaben + guthaben * zinssatz;
System.out.println("Guthaben im " + jahr + ". Jahr: " + guthaben);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,21 @@
public class Steigung {
public static void main (String args[]){
// Koordinaten x1 und y1 von Punkt P
// P(x1 | y1)
double x1 = 4;
double y1 = 6;
// Koordinaten x2 und y2 von Punkt Q
// Q(x2 | y2)
double x2 = 2;
double y2 = 1;
// m = (y2 - y1) / (x2 - x1)
double m = (y2 - y1) / (x2 - x1);
System.out.println("P(" + x1 + " | " + y1 + ")");
System.out.println("Q(" + x2 + " | " + y2 + ")");
System.out.println("Steigung zwischen P und Q: " + m);
}
}

Binary file not shown.

View File

@@ -0,0 +1,9 @@
public class Variablen{
public static void main(String args[]){
int zahl = 3;
double zahlD = (double) zahl;
System.out.println("Int: " + zahl + ", Double: " + zahlD);
}
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
public class VariablenTest{
public static void main(String args[]){
int zaehler = 3;
double zaehlerD = (double) zaehler;
double bruch = zaehler / 3.14;
final double pi = 3.1415;
System.out.println("Zaehler: " + zaehler + ", ZaehlerD: " + zaehlerD);
System.out.println("Bruch: " + bruch + ", Pi: " + pi);
}
}

View File

@@ -0,0 +1,12 @@
public class VariablenTest{
public static void main(String args[]){
int zaehler = 3;
double zaehlerD = (double) zaehler;
double bruch = zaehler / 3.14;
final double pi = 3.1415;
System.out.print("Zaehler: " + zaehler + ", ZaehlerD: " + zaehlerD);
System.out.println("Bruch: " + bruch + ", Pi: " + pi);
}
}

Binary file not shown.

View File

@@ -0,0 +1,25 @@
public class Verzweigung {
public static void main(String args[]){
int alter = 75;
if ( alter < 20 ) {
System.out.println("Du bist aber noch jung!");
}
else if ( alter < 30) {
System.out.println("Ist noch ok!");
}
else if (alter < 40 ) {
System.out.println("Grenzwertig :-P");
}
else if ( alter < 50) {
System.out.println("Die Rente ist in Sicht");
}
else if ( alter < 60 ) {
System.out.println("Bist du aber alt!");
}
else {
System.out.println("Na, ganz frisch bist du auch nicht mehr!");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,30 @@
public class VerzweigungSwitch {
public static void main(String args[]){
int zahl = 4;
switch (zahl) {
case 1:
System.out.println("Sehr gut");
break;
case 2:
System.out.println("Gut");
break;
case 3:
System.out.println("Befriedigend");
break;
case 4:
System.out.println("Ausreichend");
break;
case 5:
System.out.println("Mangelhaft");
break;
case 6:
System.out.println("Ungenügend");
break;
default:
System.out.println("Du hast keine gültige Note eingegeben!");
} // end of switch
}
}

Binary file not shown.

View File

@@ -0,0 +1,10 @@
import java.util.Arrays;
public class lottoArray{
public static void main(String args[]){
int lottozahlen[] = {17, 9, 39, 23, 41, 6};
System.out.println("Anzahl Elemente im Array: " + lottozahlen.length);
System.out.println("Komplettes Array: " + Arrays.toString(lottozahlen));
Arrays.sort(lottozahlen);
System.out.println("Komplettes Array: " + Arrays.toString(lottozahlen));
}
}