Werte tabellarisch in Java als Fenster ausgeben
Hallo...
Ich bin grad daran meine Projektaufgabe zu lösen und habe ein paar Probleme mit meiner Array Ausgabe.
Wenn ich meine zwei felder mit mehr als einen Wert füllen, dann gibt das Programm die Werte in mehreren Fenster aus. Wie kann ich es bewerkstelligen, dass die Werte in einem Fenster ausgegeben werden und alle X-Werte und X-Werte stehen und alles Y-Werte unter Y-Werte?
Vielen Dank schonmal!!!
Lg JimK
Ich bin grad daran meine Projektaufgabe zu lösen und habe ein paar Probleme mit meiner Array Ausgabe.
Wenn ich meine zwei felder mit mehr als einen Wert füllen, dann gibt das Programm die Werte in mehreren Fenster aus. Wie kann ich es bewerkstelligen, dass die Werte in einem Fenster ausgegeben werden und alle X-Werte und X-Werte stehen und alles Y-Werte unter Y-Werte?
Vielen Dank schonmal!!!
Lg JimK
import javax.swing.JOptionPane;
public class Übung8
{
public static void main(String args)
{
int zahl;
double y=null;
double x=null;
do
{
String s=JOptionPane.showInputDialog("Bitte Zahl eingeben\n1. Vektoren eingeben\n2. Ausgabe\n3. \n");
zahl=Integer.parseInt(s);
switch(zahl)
{
case 1:
String eingabe=javax.swing.JOptionPane.showInputDialog("Anzahl der Werte: ");
int n=Integer.parseInt(eingabe);
x=eingabe(n,"x");
y=eingabe(n,"y");
break;
case 2:
if ((x!=null)&&(y!=null))
ausgabe(x,y);
else
break;
case 3:
break;
}
}while(zahl<=9);
}
public static double eingabe(int n, String name)
{
double ein=new double [n];
for(int i=0; i<n; i++)
{
String t=javax.swing.JOptionPane.showInputDialog("Wert "+(1+i)+" (Vektor "+name+"): ");
ein[i]=Integer.parseInt(t);
}
return ein;
}
public static void ausgabe(double x, double y)
{
for(int i=0; i<x.length; i++)
{
String text1;
text1="X-Werte: "+x[i]+"\nY-Werte:"+y[i]+"\n";
System.out.println(text1);
javax.swing.JOptionPane.showMessageDialog(null, text1);
}
}
}
Please also mark the comments that contributed to the solution of the article
Content-Key: 143364
Url: https://administrator.de/contentid/143364
Printed on: April 25, 2024 at 17:04 o'clock