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

Ich arbeite mich gerade in BlueJ ein und brauche ein Beispiel für ein kurzes Programm, das die Funktion 40 x 2,033^12 ausrechnen kann.

(Die Zahlen sind zufällig gewählt)

Könnte vllt. jemand die Zeilen posten?

Das wäre echt super.

Danke schonmal,

Lincoln

Sorry. Ich versuch's weiter.

Moin,

mit BlueJ kommst du nicht weiter? Das Buch dazu ist doch schon ziemlich selbst erklärend und die BlueJ-Anwendung ist eigentlich auch kinderleicht...

Schreibe eine Funktion mit 3 Parametern.. x,y,z

ergebnis = x * (y^z)

so in der Art müsste das doch klappen was du vorhast..

Ich hab seit der 6. Klasse kein Informatik mehr, und in Mathe machen wir nix mit Java :(. Schule fängt bei mir am Do an.

Ich mache das hier nur zum ersten Mal, und finde kein Tutorial oder so.

Selbsterklärend ist das also leider nicht. Und ich hab kein Buch.

Ich weiß gar nicht, was wovon was bedeutet!

Und um einfach ein Gefühl zu kriegen, hatte ich auf ein Beispiel gehofft.

Dachte, das wären 5 Zeilen oder so...

Hab bisher das hier. Was fehlt?


/**

 * Write a description of class Math here.

 * 

 * @author (your name) 

 * @version (a version number or a date)

 */

public class Math

{

    // instance variables - replace the example below with your own

    private int c; int a; int t;


    /**

     * Constructor for objects of class Math

     */

    public Math()

    {

        // initialise instance variables

        c = 40; a = 2.033 ; t = 12;

    }


    /**

     * An example of a method - replace this comment with your own

     * 

     * @param  y   a sample parameter for a method

     * @return     the sum of x and y 

     */

    public int sampleMethod(int a)

    {

        // put your code here

        return x + y;

    }

}

Bearbeitet von flashpixx
Code-Tags


/**

 * Write a description of class Math here.

 * 

 * @author (your name) 

 * @version (a version number or a date)

 */

public class Math

{

    // instance variables - replace the example below with your own

    private int c; double a; int t;


    /**

     * Constructor for objects of class Math

     */

    public Math()

    {

        // initialise instance variables

        c = 40; a = 2.033 ; t = 12;

    }


    /**

     * An example of a method - replace this comment with your own

     * 

     * @param  y   a sample parameter for a method

     * @return     the sum of x and y 

     */

    public int sampleMethod(int c)

    {

        // put your code here

        return c*(a^t);

    }

}

Bearbeitet von flashpixx
Code-Tags

Ist doch schon gar nicht schlecht. Für ein Programm brauchst du noch eine Klasse, die eine main-Methode hat. Deine Berechnungsmethode braucht keinen Parameter, wenn sie sich auf die Instanzmember bezieht. Und du solltest beachten, was ich über die Bedeutung von ^ in Java geschrieben habe.

Blame on me :'(

wie konnte ich "pow" vergessen xD

Mist.. Danke Klotzkopp für die große Gedächtnissstütze ;)

*In BlueJ brauch man keine main-Methode... Da kann man die einzelnen Klassen per Rechtsklick -> ausführen starten

Wir hatten das Programm auch in der Schule.. zum einsteigen nicht schlecht, aber für komplexere Dinge dann doch lieber richtig mit z.B. eclipse programmieren lernen.

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.