Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Programm

Empfohlene Antworten

Veröffentlicht

Hallo!

hoffe mir kann einer sagen was an meiner Schleife falsch ist! Da die Schleife nicht bei der Angabe 0 aufhört! Wäre super lieb!

import java.io.*;

public class FunktionEingabe {

public static int eingabe(BufferedReader in) throws IOException {

boolean error = true;

int zahl = 0;

String help = null;

while (error) {

try {

System.out.println(" Geben sie eine Zahl ein");

help = in.readLine();

zahl = Integer.parseInt(help);

error = false;

}

catch (NumberFormatException nfe) {

error = true;

System.out.println(" Falsche Eingabe!!!!!! Geben Sie eine Zahl ein!!");

}

}

return zahl;

}

public static void main(String[] args) throws IOException {

BufferedReader in = new BufferedReader

(new InputStreamReader(System.in));

int zahl=0;

do {

System.out.println("Die eingegebene Zahl ist: " + eingabe(in));

}

while (zahl !=0);

}

}

Ok habe ich schon gelöst! Danke!

Weis jemand wie man ein Programm schreibt das die Fakultät berechnet???

Stichwort Rekursion. Die Fakultät ist so definiert:

fak(0) = 1;

fak(n) = n * fak(n-1);

Das ganze must Du jetzt nur noch programmieren. ;)

Weis jemand wie man ein Programm schreibt das die Fakultät berechnet???

Iterativ oder rekursiv?

Ciao

Christian

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.