Taschenrechner mit Java

Wir sollen in der Schule einen Taschenrechner mit Java programmieren. Wer dies nicht in der Stunde geschafft hatte sollte ihn zuhause fertig stellen. Leider war ich in den besagten Stunden leider krank und habe nun keine Ahnung wie und was ich machen soll.
Kann mir da bitte jemand helfen?

Liebe Grüße

Hey, das ist ziemlich komplex, aber ich schreib in dir hier mal rein, ich mach daraus mehrere Posts, dann ist es etwas übersichtlicher.
Ich denke mal das ihr in der Schule java.awt benutzt, haben wir zumindestens. Der Taschenrechner kann nur mit 2 Zahlen rechnen und wirft in der Konsole noch Fehler aus, aber im Grunde ist er das. Der bessere ist etwas schwieriger, dafür erstelle ich dann einen neuen Post.

________________________________________________________________________

import java.awt.*;
import java.awt.event.*;

class TaschenrechnerMain {
public static void main (String[] argv) {

Frame f=new Frame();
Panel panel = new Panel(new GridLayout( 4, 4 )); // 4 * 4 Zellen
Speichern sp = new Speichern();

f.setSize(500,200);
f.setLocation(100,100);

Button z1=new Button( „1“ );
Button z2=new Button( „2“ );
Button z3=new Button( „3“ );
Button z4=new Button( „4“ );
Button z5=new Button( „5“ );
Button z6=new Button( „6“ );
Button z7=new Button( „7“ );
Button z8=new Button( „8“ );
Button z9=new Button( „9“ );
Button z0=new Button( „0“ );
Button pl=new Button( „+“ );
Button mi=new Button( „-“ );
Button ma=new Button( „*“ );
Button ge=new Button( „/“ );
Button gl=new Button( „=“ );
Button cc=new Button( „cc“);

TextField tf=new TextField( „“, 10);
Label la=new Label();

Label em1=new Label();
Label em2=new Label();
Label em3=new Label();
Label em4=new Label();
Label em5=new Label();
Label em6=new Label();
Label em7=new Label();
Label em8=new Label();
Label em9=new Label();

f.add( panel, „Center“);
f.add( tf, „North“ );
f.add( la, „South“ );

panel.add( z1 );
panel.add( z2 );
panel.add( z3 );
panel.add( pl );
panel.add( z4 );
panel.add( z5 );
panel.add( z6 );
panel.add( mi );
panel.add( z7 );
panel.add( z8 );
panel.add( z9 );
panel.add( ma );
panel.add( cc );
panel.add( z0 );
panel.add( gl );
panel.add( ge );

pl.setBackground(new Color(0, 255, 255));
mi.setBackground(new Color(0, 255, 255));
ma.setBackground(new Color(0, 255, 255));
ge.setBackground(new Color(0, 255, 255));
gl.setBackground(new Color(0, 255, 255));
cc.setBackground(new Color(0, 255, 255));

Fensterschlieser fs=new Fensterschlieser();
f.addWindowListener(fs);

Taschenrechner re0=new Taschenrechner(tf, la, 0);
z0.addActionListener(re0);
Taschenrechner re1=new Taschenrechner(tf, la, 1);
z1.addActionListener(re1);
Taschenrechner re2=new Taschenrechner(tf, la, 2);
z2.addActionListener(re2);
Taschenrechner re3=new Taschenrechner(tf, la, 3);
z3.addActionListener(re3);
Taschenrechner re4=new Taschenrechner(tf, la, 4);
z4.addActionListener(re4);
Taschenrechner re5=new Taschenrechner(tf, la, 5);
z5.addActionListener(re5);
Taschenrechner re6=new Taschenrechner(tf, la, 6);
z6.addActionListener(re6);
Taschenrechner re7=new Taschenrechner(tf, la, 7);
z7.addActionListener(re7);
Taschenrechner re8=new Taschenrechner(tf, la, 8);
z8.addActionListener(re8);
Taschenrechner re9=new Taschenrechner(tf, la, 9);
z9.addActionListener(re9);

Plus plus=new Plus(tf, la, sp);
pl.addActionListener(plus);

Minus minus=new Minus(tf, la, sp);
mi.addActionListener(minus);

Mal mal=new Mal(tf, la, sp);
ma.addActionListener(mal);

Geteilt geteilt=new Geteilt(tf, la, sp);
ge.addActionListener(geteilt);

Gleich gleich=new Gleich(tf, la, sp);
gl.addActionListener(gleich);

Clear clear=new Clear(tf, la, sp);
cc.addActionListener(clear);

f.setVisible(true);
}
}

Die Ziffern
import java.awt.*;
import java.awt.event.*;

public class Taschenrechner implements ActionListener {

TextField TF;
Label LA;
int Ziffer;

Taschenrechner(TextField tf, Label la, int ziffer) {
TF = tf;
LA = la;
Ziffer = ziffer;
}

public void actionPerformed(ActionEvent ae) {
if(TF.getText().equals(„0“) && Ziffer==0) {
LA.setText(„Bitte keine weitere Null schreiben“);
} else {
TF.setText(TF.getText()+Ziffer);
}

LA.setText("");
}
}

Das Speichern der Ziffern
public class Speichern {

private Float ersteZahl;
private String OP;

Speichern() {
}

void setzeZahl(Float Zahl){
ersteZahl = Zahl;
}

void setzeOperation(String op){
OP = op;
}

Float gebeZahl() {
return ersteZahl;
}

String gebeOperation() {
return OP;
}
}

Der Pluss Button (Minus, Mal, Geteilt ist genauso)
import java.awt.*;
import java.awt.event.*;

public class Plus implements ActionListener {

TextField TF;
Label LA;
Speichern SP;

Plus(TextField tf, Label la, Speichern sp) {
TF = tf;
SP = sp;
LA = la;
}

public void actionPerformed(ActionEvent aepl) {
SP.setzeZahl(Float.parseFloat(TF.getText()));
SP.setzeOperation("+");

LA.setText("");
TF.setText("");
}
}

Der Gleich Button
import java.awt.*;
import java.awt.event.*;

public class Gleich implements ActionListener {

TextField TF;
Label LA;
Speichern SP;

Float ersteZahl;
Float letzteZahl;
Float Ergebnis;

String op;

Gleich(TextField tf, Label la, Speichern sp) {
TF = tf;
LA = la;
SP = sp;
}

public void actionPerformed(ActionEvent aegl) {
letzteZahl=Float.parseFloat(TF.getText());
ersteZahl=SP.gebeZahl();
op=SP.gebeOperation();

if(op=="") {
SP.setzeZahl(Float.parseFloat(TF.getText()));
ersteZahl=SP.gebeZahl();
Ergebnis=ersteZahl;
}
if(op=="+") {
Ergebnis=ersteZahl+letzteZahl;
}
if(op=="-") {
Ergebnis=ersteZahl-letzteZahl;
}
if(op=="*") {
Ergebnis=ersteZahl*letzteZahl;
}
if(op=="/") {
Ergebnis=ersteZahl/letzteZahl;
}

LA.setText(„Das Ergebnis ist: „+Ergebnis);
SP.setzeOperation(““);
TF.setText("");
}
}

Um die Eingaben zu löschen
import java.awt.*;
import java.awt.event.*;

public class Clear implements ActionListener {

TextField TF;
Label LA;
Speichern SP;

Clear(TextField tf, Label la, Speichern sp) {
TF = tf;
SP = sp;
LA = la;
}

public void actionPerformed(ActionEvent aecc) {
SP.setzeZahl(0.f);
SP.setzeOperation("");

LA.setText("");
TF.setText("");
}
}

Damit man das Fenster schliesen kann
import java.awt.*;
import java.awt.event.*;

class Fensterschlieser extends WindowAdapter {

Fensterschlieser() {
}

public void windowClosing(WindowEvent we) {
System.exit(0);
}
public void windowActivated(WindowEvent we1) {
}
public void windowClosed(WindowEvent we2) {
}
public void windowDeactivated(WindowEvent we4) {
}
public void windowDeiconified(WindowEvent we5) {
}
public void windowGainedFocus(WindowEvent we6) {
}
public void windowIconified(WindowEvent we7) {
}
public void windowLostFocus(WindowEvent we8) {
}
public void windowOpened(WindowEvent we9) {
}
public void windowStateChanged(WindowEvent we10) {
}
}

Hier der verbesserte Taschenrechner ohne Fehler
import java.awt.*;
import java.awt.event.*;

class TaschenrechnerMain {
public static void main (String[] argv) {

Frame f = new Frame();
Panel panel = new Panel(new GridLayout( 4, 4 )); // 4 * 4 Zellen
Panel abschluss = new Panel(new GridLayout( 3, 1 ));
Float ergebnis = 0.f;

f.setSize(300,300);
f.setLocation(200,200);

Button z1=new Button( „1“ );
Button z2=new Button( „2“ );
Button z3=new Button( „3“ );
Button z4=new Button( „4“ );
Button z5=new Button( „5“ );
Button z6=new Button( „6“ );
Button z7=new Button( „7“ );
Button z8=new Button( „8“ );
Button z9=new Button( „9“ );
Button z0=new Button( „0“ );
Button pl=new Button( „+“ );
Button mi=new Button( „-“ );
Button ma=new Button( „*“ );
Button ge=new Button( „/“ );
Button gl=new Button( „=“ );
Button cc=new Button( „cc“);

TextField tf = new TextField( „“, 10);
Label la = new Label();
Label zwErgebnis = new Label();
Label credits = new Label( „Made by Jost Pape“);
Label em=new Label();

f.add( panel, „Center“);
f.add( tf, „North“ );
f.add( abschluss, „South“);
abschluss.add( zwErgebnis );
abschluss.add( la );
abschluss.add( credits );

panel.add( z1 );
panel.add( z2 );
panel.add( z3 );
panel.add( pl );
panel.add( z4 );
panel.add( z5 );
panel.add( z6 );
panel.add( mi );
panel.add( z7 );
panel.add( z8 );
panel.add( z9 );
panel.add( ma );
panel.add( cc );
panel.add( z0 );
panel.add( gl );
panel.add( ge );

pl.setBackground(new Color(0, 255, 255));
mi.setBackground(new Color(0, 255, 255));
ma.setBackground(new Color(0, 255, 255));
ge.setBackground(new Color(0, 255, 255));
gl.setBackground(new Color(0, 255, 255));
cc.setBackground(new Color(0, 255, 255));

Fensterschlieser fs=new Fensterschlieser();
f.addWindowListener(fs);

Speichern sp = new Speichern(zwErgebnis);

Taschenrechner re0=new Taschenrechner(tf, la, sp, 0);
z0.addActionListener(re0);
Taschenrechner re1=new Taschenrechner(tf, la, sp, 1);
z1.addActionListener(re1);
Taschenrechner re2=new Taschenrechner(tf, la, sp, 2);
z2.addActionListener(re2);
Taschenrechner re3=new Taschenrechner(tf, la, sp, 3);
z3.addActionListener(re3);
Taschenrechner re4=new Taschenrechner(tf, la, sp, 4);
z4.addActionListener(re4);
Taschenrechner re5=new Taschenrechner(tf, la, sp, 5);
z5.addActionListener(re5);
Taschenrechner re6=new Taschenrechner(tf, la, sp, 6);
z6.addActionListener(re6);
Taschenrechner re7=new Taschenrechner(tf, la, sp, 7);
z7.addActionListener(re7);
Taschenrechner re8=new Taschenrechner(tf, la, sp, 8);
z8.addActionListener(re8);
Taschenrechner re9=new Taschenrechner(tf, la, sp, 9);
z9.addActionListener(re9);

Plus plus=new Plus(tf, la, sp);
pl.addActionListener(plus);

Minus minus=new Minus(tf, la, sp);
mi.addActionListener(minus);

Mal mal=new Mal(tf, la, sp);
ma.addActionListener(mal);

Geteilt geteilt=new Geteilt(tf, la, sp);
ge.addActionListener(geteilt);

Gleich gleich=new Gleich(tf, la, sp, zwErgebnis);
gl.addActionListener(gleich);

Clear clear=new Clear(tf, la, sp, zwErgebnis);
cc.addActionListener(clear);

f.setVisible(true);
}
}

Die Ziffern
import java.awt.*;
import java.awt.event.*;

public class Taschenrechner implements ActionListener {

TextField TF;
Label LA;
Speichern SP;
int Ziffer;

Taschenrechner(TextField tf, Label la, Speichern sp, int ziffer) {
TF = tf;
LA = la;
SP = sp;
Ziffer = ziffer;
}

public void actionPerformed(ActionEvent ae) {
if(TF.getText().equals(„0“) && Ziffer==0) {
LA.setText(„Bitte keine weitere Null schreiben“);
} else {
if(SP.gebeOperation().equals("")) {
SP.setzeZahl(0.f);
TF.setText(TF.getText()+Ziffer);
} else {
TF.setText(TF.getText()+Ziffer);
}
}

LA.setText("");
}
}

Das Speichern der Ziffern
import java.awt.*;
import java.awt.event.*;

public class Speichern {

private Float ersteZahl=0.f;
private String OP="";
Label ZWErgebnis;

Speichern(Label zwErgebnis) {
ZWErgebnis = zwErgebnis;
}

void setzeOperation(String op) {
OP = op;
}

void setzeZahl(Float Zahl) {
if(OP=="") {
ersteZahl=Zahl;
}
if(OP=="+") {
ersteZahl=ersteZahl+Zahl;
ZWErgebnis.setText(„Zwischenergebnis: „+ersteZahl);
}
if(OP==“-“) {
ersteZahl=ersteZahl-Zahl;
ZWErgebnis.setText(„Zwischenergebnis: „+ersteZahl);
}
if(OP==“*“) {
ersteZahl=ersteZahl*Zahl;
ZWErgebnis.setText(„Zwischenergebnis: „+ersteZahl);
}
if(OP==“/“) {
ersteZahl=ersteZahl/Zahl;
ZWErgebnis.setText("Zwischenergebnis: "+ersteZahl);
}
}

String gebeOperation() {
return OP;
}

Float gebeZahl() {
return ersteZahl;
}
}

Der Plus Button (Mal, Geteilt ist wieder genauso)
import java.awt.*;
import java.awt.event.*;

public class Plus implements ActionListener {

TextField TF;
Label LA;
Speichern SP;

Plus(TextField tf, Label la, Speichern sp) {
TF = tf;
SP = sp;
LA = la;
}

public void actionPerformed(ActionEvent aepl) {
if(SP.gebeZahl()==0.f && ! TF.getText().equals("")) {
try {
SP.setzeZahl(Float.parseFloat(TF.getText()));
SP.setzeOperation("+");
TF.setText("");
} catch (Exception epl) {
LA.setText(„Das können sie nicht machen“);
}
} else {
if(SP.gebeZahl()==0.f && TF.getText().equals("")) {
LA.setText(„Das können sie nicht machen“);
} else {
if(TF.getText().equals("")) {
SP.setzeOperation("+");
} else {
SP.setzeZahl(Float.parseFloat(TF.getText()));
SP.setzeOperation("+");
TF.setText("");
}
}
}
}
}

Der Minus Button (ist etwas anders)
import java.awt.*;
import java.awt.event.*;

public class Minus implements ActionListener {

TextField TF;
Label LA;
Speichern SP;

Minus(TextField tf, Label la, Speichern sp) {
TF = tf;
SP = sp;
LA = la;
}

public void actionPerformed(ActionEvent aemi) {
if(SP.gebeZahl()==0.f && ! TF.getText().equals("")) {
try {
SP.setzeZahl(Float.parseFloat(TF.getText()));
SP.setzeOperation("-");
TF.setText("");
} catch (Exception emi) {
LA.setText(„Das können sie nicht machen“);
}
} else {
if(SP.gebeZahl()==0.f && TF.getText().equals("")) {
TF.setText("-");
} else {
if(TF.getText().equals("")) {
SP.setzeOperation("-");
} else {
SP.setzeZahl(Float.parseFloat(TF.getText()));
SP.setzeOperation("-");
TF.setText("");
}
}
}
}
}

Der Gleich Button
import java.awt.*;
import java.awt.event.*;

public class Gleich implements ActionListener {

TextField TF;
Label LA;
Speichern SP;
Label ZWErgebnis;

Float ersteZahl;
Float letzteZahl;
Float Ergebnis;

String op;

Gleich(TextField tf, Label la, Speichern sp, Label zwErgebnis) {
TF = tf;
LA = la;
SP = sp;
ZWErgebnis = zwErgebnis;
}

public void actionPerformed(ActionEvent aegl) {
try {
letzteZahl=Float.parseFloat(TF.getText());
ersteZahl=SP.gebeZahl();
op=SP.gebeOperation();

if(op=="") {
SP.setzeZahl(Float.parseFloat(TF.getText()));
ersteZahl=SP.gebeZahl();
Ergebnis=ersteZahl;
}
if(op=="+") {
Ergebnis=ersteZahl+letzteZahl;
}
if(op=="-") {
Ergebnis=ersteZahl-letzteZahl;
}
if(op=="*") {
Ergebnis=ersteZahl*letzteZahl;
}
if(op=="/") {
try {
Ergebnis=ersteZahl/letzteZahl;
} catch (Exception ex) {
LA.setText(„Sie können nicht durch Null teilen“);
}
}

LA.setText(„Das Ergebnis ist: „+Ergebnis);
SP.setzeOperation(““);

ZWErgebnis.setText("");
TF.setText("");
SP.setzeZahl(Ergebnis);
} catch (Exception egl) {
}
}
}

Hier löscht man die Eingaben fast genauso
import java.awt.*;
import java.awt.event.*;

public class Clear implements ActionListener {

TextField TF;
Label LA;
Speichern SP;
Label ZWErgebnis;

Clear(TextField tf, Label la, Speichern sp, Label zwErgebnis) {
TF = tf;
SP = sp;
LA = la;
ZWErgebnis = zwErgebnis;
}

public void actionPerformed(ActionEvent aecc) {
SP.setzeOperation("");
SP.setzeZahl(0.f);

LA.setText("");
TF.setText("");
ZWErgebnis.setText("");
}
}

Fertig
Das wäre dann alles, ich hoffe ich konnte helfen.
Wenn ja würde ich mich über ein Sternchen freuen.

Grüße Morslord

Je nach dem ob garfisch:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

/**
*
* Beschreibung
*
* @version 1.0 vom 05.10.2010
* @author
*/

public class Taschenrechner extends JFrame {
// Anfang Attribute
static String zahl1;
static String zahl2;
static String zahl3;
static String zahl4;
static double zahl5;
static double zahl6;
static double ergebnis;

private JLabel label1 = new JLabel();
private JLabel label2 = new JLabel();
private JLabel label3 = new JLabel();
private JButton button1 = new JButton();
private JButton button2 = new JButton();
private JButton button3 = new JButton();
private JButton button4 = new JButton();
private JTextField textField1 = new JTextField();
private JTextField textField2 = new JTextField();
private JTextField textField3 = new JTextField();
// Ende Attribute

public Taschenrechner(String title) {
// Frame-Initialisierung
super(title);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int frameWidth = 275;
int frameHeight = 265;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x, y);
Container cp = getContentPane();
cp.setLayout(null);
// Anfang Komponenten
label1.setBounds(8, 8, 90, 16); //links; oben; länge; höhe
label1.setText(„Ihre 1.Zahl: „);
label1.setFont(new Font(„MS Sans Serif“, Font.PLAIN, 13));
cp.add(label1);
label2.setBounds(8, 33, 90, 16);
label2.setText(„Ihre 2.Zahl: „);
label2.setFont(new Font(„MS Sans Serif“, Font.PLAIN, 13));
cp.add(label2);
label3.setBounds(8, 188, 90, 16);
label3.setText(““);
label3.setFont(new Font(„MS Sans Serif“, Font.PLAIN, 13));
cp.add(label3);
button1.setBounds(130, 60, 90, 25);
button1.setLabel(“+“);
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button1_ActionPerformed(evt);
}
});
cp.add(button1);
button2.setBounds(130, 85, 90, 25);
button2.setLabel("-");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button2_ActionPerformed(evt);
}
});
cp.add(button2);
button3.setBounds(130, 110, 90, 25);
button3.setLabel(„x“);
button3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button3_ActionPerformed(evt);
}
});
cp.add(button3);
button4.setBounds(130, 135, 90, 25);
button4.setLabel(":");
button4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button4_ActionPerformed(evt);
}
});
cp.add(button4);
textField1.setBounds(128, 8, 121, 24);
textField1.setText("");
cp.add(textField1);
textField2.setBounds(128, 33, 121, 24);
textField2.setText("");
cp.add(textField2);
textField3.setBounds(8, 188, 241, 24);
textField3.setText(„Ergebnis:“);
cp.add(textField3);
// Ende Komponenten

setResizable(false);
setVisible(true);
}

// Anfang Methoden
public void button1_ActionPerformed(ActionEvent evt) {

zahl1 = (textField1.getText());
zahl2 = (textField2.getText());
zahl3 = zahl1.replace(",", „.“);
zahl4 = zahl2.replace(",", „.“);
zahl5 = Double.parseDouble (zahl3);
zahl6 = Double.parseDouble (zahl4);
ergebnis = zahl5+zahl6;
textField3.setText(""+ergebnis);
}
public void button2_ActionPerformed(ActionEvent evt) {
zahl1 = (textField1.getText());
zahl2 = (textField2.getText());
zahl3 = zahl1.replace(",", „.“);
zahl4 = zahl2.replace(",", „.“);
zahl5 = Double.parseDouble (zahl3);
zahl6 = Double.parseDouble (zahl4);
ergebnis = zahl5-zahl6;
textField3.setText(""+ergebnis);
}
public void button3_ActionPerformed(ActionEvent evt) {
zahl1 = (textField1.getText());
zahl2 = (textField2.getText());
zahl3 = zahl1.replace(",", „.“);
zahl4 = zahl2.replace(",", „.“);
zahl5 = Double.parseDouble (zahl3);
zahl6 = Double.parseDouble (zahl4);
ergebnis = zahl5*zahl6;
textField3.setText(""+ergebnis);
}
public void button4_ActionPerformed(ActionEvent evt) {
zahl1 = (textField1.getText());
zahl2 = (textField2.getText());
zahl3 = zahl1.replace(",", „.“);
zahl4 = zahl2.replace(",", „.“);
zahl5 = Double.parseDouble (zahl3);
zahl6 = Double.parseDouble (zahl4);
ergebnis = zahl5/zahl6;
if ( zahl6 == 0 )
{
textField3.setText(„Du kannst nicht durch Null teilen.“);
}
else
{
textField3.setText(""+ergebnis);
}
}
// Ende Methoden

public static void main(String[] args) {
new Taschenrechner(„Taschenrechner“);
}
}

oder „konsolisch“:

import java.io.*;

public class TaschenRechner
{
static double zahl1;
static double zahl2;
static double ergebnis;
static String zeichen;

public static void main(String[] args)
{
BufferedReader bk = new BufferedReader (new InputStreamReader(System.in));

System.out.print("Ihre 1 Zahl= ");
try
{
zahl1 = Double.parseDouble(bk.readLine());
} catch (Exception e) {}

System.out.print("Zeichen= ");
try
{
zeichen = bk.readLine();
} catch (Exception e) {}

System.out.print("Ihre 2 Zahl= ");
try
{
zahl2 = Double.parseDouble(bk.readLine());
} catch (Exception e) {}

if (zeichen.equals("+"))
{
ergebnis=zahl1 + zahl2;
System.out.print(zahl1 + " " + zeichen + " " + zahl2 + " ist " +ergebnis);
} else if (zeichen.equals("-"))
{
ergebnis=zahl1 - zahl2;
System.out.print(zahl1 + " " + zeichen + " " + zahl2 + " ist " +ergebnis);
} else if (zeichen.equals("*"))
{
ergebnis=zahl1 * zahl2;
System.out.print(zahl1 + " " + zeichen + " " + zahl2 + " ist " +ergebnis);
} else if (zeichen.equals("/"))
{
if (zahl2 == 0)
{
ergebnis=zahl1 / zahl2;
System.out.print("Du kannst nicht durch null teilen, somit ist " + zahl1 + " " + zeichen + " " + „null“ + " " +ergebnis);
}
else
{
ergebnis=zahl1 / zahl2;
System.out.print(zahl1 + " " + zeichen + " " + zahl2 + " ist " +ergebnis);
}
} else
{
System.out.print(„Error“);
}
}
}

LG Denni