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.

Anfänger hat Probleme

Empfohlene Antworten

Veröffentlicht

import Prog1Tools.IOTools;

public class Mastermind

{

/**

* Hauptmethode des Programms

*

* @param args die, dem Programm uebergebenen Parameter

*/

public static void main(String[] args)

{

float zahl;

System.out.println("Mastermind");

System.out.println("============");

System.out.println();

eingabe(zahl);

System.out.println(zahl);

}

public static float eingabe(float zahl)

{

System.out.println("Sie müssen eine vierstellige Zahlenfolge eingeben, dabei muss folgendes beachtet werden: Es darf keine Zahl zwischen 1 und 9 doppelt vorkommen. Sonst wird ein Fehler ausgegeben.");

zahl=IOTools.readFloat("Zahl eingeben: ");

return zahl;

}

}

ich habe ein Problem, bei dem Teil mit der Fettschrift!

Bei der Übergabe der Zahl gibt es ein Compiler-Fehler, weis nicht, wo der Fehler liegt.

Weis jemand, wo ich was falsch gemacht habe?

stimmt die Rückgabe des Wertes zahl?

Hm, ich seh da gleich mehrere Fehler.

float zahl; //wert der variable ist null

1.eingabe(zahl); //zahl ist immernoch null, der Returnwert wird nicht zugewiesen

2.System.out.println(zahl); //zahl ist immernoch null

float wird als Wert übergeben. Pointer gibt es in Java nicht.

Mein Vorschlag wäre:


...main(...)
{
float zahl;
......
zahl = eingabe(); // zahl nicht übergeben, aber zuweisen
......
}

public static float eingabe()
{
float zahl;
zahl = IOTools.readFloat("Zahl eingeben: ");//hab keine Ahnung was das macht
return zahl;
}

[/php]

Emrep

...main(...)

{

float zahl;

......

zahl = eingabe(); // zahl nicht übergeben, aber zuweisen // Es Funktioniert so!

......

}

public static float eingabe()

{

float zahl;

zahl = IOTools.readFloat("Zahl eingeben: ");//hab keine Ahnung was das macht // das ist die Eingabe

return zahl;

}

danke für die Hilfe!

habe davor C++ gelernt und jetzt ein Umsteiger auf Java wegen der Schule!

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.