~~NOTOC~~ ====== Lösungsvorschläge ====== Die Lösungsvorschläge sind absichtlich unkommentiert. Du solltest sie verstehen und deinem Banknachbarn erklären können, damit sie einen Nutzen haben((Einfach nur Cut'n'Paste funktioniert zwar, Ändert aber nicht am Zustand deines Gehirns...)). Idealerweise fügst du nach der Besprechung entsprechende Kommentare in den Code ein. ===== A01 ===== ++++ Lösungsvorschlag A01| public int 01MyModulo(int a, int b) { int remainder=0; // dein Code remainder = a - a/b*b; // Rückgabe return remainder; } oder public int MyModulo(int a, int b) { return a - a/b*b; } ++++ ===== A02 ===== ++++ Lösungsvorschlag A02| public void Switch(int a, int b) { System.out.println("Eingabe - a="+ a + " b="+b); int c; c=a; a=b; b=c; System.out.println("Ausgabe - a="+ a + " b="+b); } public void Switch(int a, int b) { System.out.println("Eingabe - a="+ a + " b="+b); b = a + b; a = b - a; b = b - a; System.out.println("Ausgabe - a="+ a + " b="+b); } ++++ ===== A03 ===== ++++ Lösungsvorschlag A03 | public double a03Pyramide(double h, double a) { double v = 1.0/3.0*h*a*a; return v; } ++++ ===== A04 ===== ++++Lösungsvorschlag A04 | public void a04Alterstest(int alter) { if ( alter < 7 ) { System.out.println("Nicht geschäftsfähig"); } else if ( alter < 18) { System.out.println("Eingeschränkt geschäftsfähig"); } else { System.out.println("Voll geschäftsfähig"); } } ++++ ===== A05 ===== ++++ Lösungsvorschlag A05 | public String a06gerade (int zahl) { int istungerade; istungerade = zahl % 2; if (istungerade == 0 ) { return "Zahl "+ zahl +" ist gerade"; } else { return "Zahl "+ zahl +" ist ungerade"; } } ++++ ===== A06 ===== ++++ Lösungsvorschlag A06 - 1 | public String a06schulnoten (double kommanote) { String textnote = ""; kommanote = kommanote*100; if (kommanote >= 550.0 ) { textnote = "Ungenügend"; } else if (kommanote >= 450.0 ) { textnote = "Mangelhaft"; } else if (kommanote >= 350.0 ) { textnote = "Ausreichend"; } else if (kommanote >= 250.0 ) { textnote = "Befriedigend"; } else if (kommanote >= 150.0 ) { textnote = "Gut"; } else { textnote = "Sehr gut"; } return textnote; } ++++ ++++ Lösungsvorschlag A06 - 2 | public String a06schulnoten_2 (double kommanote) { String textnote = ""; int ganzenote; // Was passiert hier? Erkläre! ganzenote = (int) (kommanote*100+50)/100; switch(ganzenote){ case 1: textnote = "Sehr gut"; break; case 2: textnote = "Gut"; break; case 3: textnote = "Befriedigend"; break; case 4: textnote = "Ausreichend"; break; case 5: textnote = "Mangelhaft"; break; case 6: textnote = "Ungenügend"; break; } return textnote; } ++++ ===== A08 ===== ++++ Lösungsvorschlag A08 | public boolean a08schaltjahr(int jahr) { if ( (jahr % 4 == 0 && jahr % 100 != 0 && jahr % 400 != 0) || (jahr % 400 == 0) ) { return true; } return false; } ++++ ===== A09 ===== ++++ Lösungsvorschlag A09 | public int a09stellenzaehler(int zahl) { int stellen=0; while (zahl > 0) { zahl = zahl / 10; stellen++; } return stellen; } ++++ ===== A11 ===== ++++ Lösungsvorschlag A11 | public int a11dual2dec(int dual) { int stellenziffer=0; int stellenwert=1; int dezimalwert=0; while (dual > 0) { stellenziffer = dual % 10; dezimalwert = dezimalwert + stellenziffer * stellenwert; stellenwert = stellenwert * 2; dual = dual / 10; } return dezimalwert; } ++++ ===== A12 ===== ++++ Lösungsvorschlag A12 | public int a12zahlendreher(int zahl) { int stellenziffer=0; int stellenwert=1; int temp; int umgedreht=0; temp = zahl; while (temp > 0) { temp = temp / 10; stellenwert = stellenwert * 10; } stellenwert = stellenwert / 10; temp = zahl; while (temp > 0) { stellenziffer = temp % 10; umgedreht = umgedreht + stellenziffer * stellenwert; stellenwert = stellenwert / 10; temp = temp / 10; } return umgedreht; } ++++ ===== A13 ===== ++++ Lösungsvorschlag A13 | public double a13pi(int n, boolean watch) { double pi4=0.0; double nenner=1.0; for (int i=0; i ++++ ===== A14 ===== ++++ Lösungsvorschlag A14 | public void a14quadrat(int n) { for (int i=0; i ++++ ===== A15 ===== ++++ Lösungsvorschlag A15 | public void a15dreieck(int n) { for (int i=0; i<=n;i++) { for(int j=0; j ++++ ===== A15 ===== ++++ Lösungsvorschlag A | ++++ ===== A16 ===== ++++ Lösungsvorschlag A16 | public void a16lottozahlen () { int anzahl = 9; int[] lzahlen = new int[anzahl]; for (int i = 0; i ++++