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.

Array in Integer einfügen

Empfohlene Antworten

Veröffentlicht

Hallo.

Verzweifele gerade an folgender Aufgabe:confused:

mport javax.swing.*;

public class arrey {

public static void main(String[] args)

{

double[] daten;

daten = new double [4] ;

daten [0]=45;

daten [1]= 56;

daten [2]= 56.765;

System.out.println("Die "+daten.length+" Zahlen sind:");

for (int i = 0; i<daten.length;i=i+1)

{

System.out.println(daten);

}

//System.out.println(daten [0]);

//System.out.println(daten [1]);

//System.out.println(daten [2]);

}

}

Jetz muss ich das Programm so schreiben, dass double[] daten;

daten = new double [4] ; als String a = JOptionPane.showInputDialog("Erste Zahl eingeben:");

int zahl1=Integer.parseInt (a);

erscheinen nur mit double

Wie mach ich das?

Kann mir vielleicht jemand helfen?

Vielen Dank im Voraus.

Lexa

was ist los ?

meinst du Double.intValue()

hi.

Das mit double ist mir schon klar.

Ich muss die 10 daten = new double [10];

Durch den Eingefügten Dialog eingeben können,

es soll ein Fenster erscheinen, dass mich fordert die Anzahl des Arrays einzugeben.

Hoffe es ist verständlich.

Danke

quick and dirty

public class JOP_test {



	public JOP_test(){

		double[] db = {0,0,0,0,0,0,0,0,0,0,0,0,0};


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

			String a = JOptionPane.showInputDialog("Zahl "+(i+1)+" eingeben:");

			db[i] = Integer.parseInt(a);

		}


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

			System.out.println("Die Zahl "+(i+1)+" ist "+db[i]);

		}

	}


	/**

	 * @param args

	 */

	public static void main(String[] args) {

		new JOP_test();


	}


}

Danke!!!:)

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.