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.

Empfohlene Antworten

Veröffentlicht

Hallo, habe ein Programm für Wertetabellen von mathematischen Funktionen geschrieben. Leider kann ich das Programm nicht kompilieren, mir wird angezeigt: cannot find symbol, symbol : variable IO1

Könnt ihr mir helfen?

public class AA{


  /**

   * @param args

   */

  public static void main(String[] args) {


    String[] Funktionen = { "Berechnung des Logarithmus",

        "Berechnung einer trigonometrischen Funktion",

        "Berechnung eines Polynoms" };


    System.out.println("Dies sind die mathematischen Funktionen");

    System.out.println("");

    for (int i = 0; i < 3; i++) {

      System.out.println(i + "." + Funktionen[i]);

      if (i != 2)

        continue;


      int m, a, N;

      int d = 0;

      double Ergebnis = 0, x = 0;


      do {

        System.out.println("");

        System.out

            .println("Bitte geben Sie die gewünschte Berechnung an.");

        m = IO1.einint();


        System.out

            .println("Bitte geben Sie eine rationale Zahl als Startwert ein.");

        a = IO1.einint();


        System.out

            .println("Bitte geben Sie eine rationale Schrittweite > 0 ein.");

        d = IO1.einint();

        if (d <= 0)

          System.out.println(d + " liegt nicht über Null.");


      } while ((d <= 0) && (m >= 0) && (m <= 2));


      System.out

          .println("Bitte geben Sie eine natürliche Zahl für die anzahl der zu berechnenden x-Werte ein.");

      N = IO1.einint();


      switch (m) {

      case 0:

        for (i = a; i <= N; i++) {

          x = a + i * d;

          Ergebnis = Math.log(x);

          System.out.println("x= " + x + " y= " + Ergebnis);


        }

        break;


      case 1:

        for (i = a; i <= N; i++) {

          x = a + i * d;

          Ergebnis = Math.sin(x);

          System.out.println("x= " + x + " y= " + Ergebnis);


        }

        break;


      case 2:

        for (i = a; i <= N; i++) {

          x = a + i * d;

          Ergebnis = x * (x * x - x - 12);

          System.out.println("x= " + x + " y= " + Ergebnis);

        }

        break;


      default:

        System.out.println("Unzulässiger Modus");


        break;


      }

    }

  }

}


Aber wie deklariere ich das denn? ich habe diverse andere Java-Programme aus dem Internet, die eine Tastatureingabe erfordern, ausprobiert, und bekomme da immer denselben Fehler.

import java.io.*;


class AA

{

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

geht das in die richtige Richtung?


int m, a, N;  // nur deklarieren

int d = 0; // deklarieren und initialisieren

double Ergebnis = 0, x = 0; // deklarieren und initialisieren

Deklarationen haben die Form:

[<MODIFIER>] <TYP> <NAME>;

Initialisierungen:

<NAME> = <WERT>|<KONSTRUKTOR>|<METHODEN_AUFURUF>;

Bei dir Fehlt also etwas in der Form:

<TYP> IO1 = <KONSTRUKTUR>|<METHODEN_AUFURUF>;

Hi!

So wie du

N = IO1.einint();

verwendest müsste IO1 eine Klasse sein, die über eine statische Methode einint() verfügt.

Ich nehme mal an, dass du dir da aus irgendeinem Tutorial Beispielcode hergenommen hast und übersehen hast, dass da vorher irgendwo eine entsprechende Klasse definiert wurde?

hab eine IO1.class-Datei gefunden, die im selben Verzechnis abgelegt wird wie das Programm und die andere .class-Datei. Jetzt läuft das Programm. Danke für die Hilfestellung.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.