Äh - nö!zahl2, zahl2 ??
Oh Gott! Ich glaub mir wird schlecht...wobei zahl1 ja auch ein Parameter ist. alle 3 sind Parameter. Er würde halt von 3 Parametern ausgehen. zahl2 2 mal nehmen.
Oh Gott! Ich glaub mir wird schlecht...
Hohl?*Taschentuch* überreich Ich bin wie eine Flasche Wein.
public class Taschenrechner {
public static int summe(int x, int y) {
return (x + y);
}
public static int differenz(int x, int y) {
return (x - y);
}
public static int produkt(int x, int y) {
return (x * y);
}
public static int quotientenwert(int x, int y) {
return (x / y);
}
//Klassenmethode potenz, die 2 Parameter ( int basis & int expoWert hat)
public static long potenz(int basis, int expoWert) {
long result = 1;
while(expoWert > 0) {
result *= basis;
expoWert--;
}
return result;
}
public static void main(String[] args) {
// TODO Automatisch generierter Methodenstub
int zahl1, zahl2;
String eingabe;
zahl1 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre erste Zahl ein:"));
zahl2 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre zweite Zahl ein:"));
eingabe = JOptionPane.showInputDialog("Tippen Sie das Rechenzeichen ein (+, -, *, /,^):");
switch(eingabe)
{
case "+":
System.out.println("Resultat = " + summe(zahl1, zahl2));
break;
case "-":
System.out.println("Resultat = " + differenz(zahl1, zahl2));
break;
case "*":
System.out.println("Resultat = " + produkt(zahl1, zahl2));
break;
case "/":
System.out.println("Resultat = " + quotientenwert(zahl1, zahl2));
break;
case "^":
System.out.println("Resultat = " + potenz(zahl1, zahl2));
break;
}
}
}
public class Taschenrechner {
public static int summe(int x, int y) {
return (x + y);
}
public static int differenz(int x, int y) {
return (x - y);
}
public static int produkt(int x, int y) {
return (x * y);
}
public static int quotientenwert(int x, int y) {
return (x / y);
}
public static long potenz(int basis, int expoWert) {
long result = 1;
while(expoWert > 0) {
result *= basis;
expoWert--;
}
return result;
}
public static void main(String[] args) {
int zahl1, zahl2;
String eingabe;
zahl1 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre erste Zahl ein:"));
zahl2 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre zweite Zahl ein:"));
eingabe = JOptionPane.showInputDialog("Tippen Sie das Rechenzeichen ein (+, -, *, /,^):");
switch(eingabe) {
case "+":
System.out.println("Resultat = " + summe(zahl1, zahl2));
break;
case "-":
System.out.println("Resultat = " + differenz(zahl1, zahl2));
break;
case "*":
System.out.println("Resultat = " + produkt(zahl1, zahl2));
break;
case "/":
System.out.println("Resultat = " + quotientenwert(zahl1, zahl2));
break;
case "^":
System.out.println("Resultat = " + potenz(zahl1, zahl2));
break;
}
}
}
public class Taschenrechner {
public static int summe(int x, int y) {
return (x + y);
}
public static int differenz(int x, int y) {
return (x - y);
}
public static int produkt(int x, int y) {
return (x * y);
}
public static int quotientenwert(int x, int y) {
return (x / y);
}
//Klassenmethode potenz, die 2 Parameter ( int basis & int expoWert hat)
public static long potenz(int basis, int expoWert) {
long result = 1;
while(expoWert > 0) {
result *= basis;
expoWert--;
}
return result;
}
public static void main(String[] args) {
// TODO Automatisch generierter Methodenstub
int zahl1, zahl2;
String eingabe;
zahl1 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre erste Zahl ein:"));
zahl2 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre zweite Zahl ein:"));
eingabe = JOptionPane.showInputDialog("Tippen Sie das Rechenzeichen ein (+, -, *, /,^):");
switch(eingabe)
{
case "+":
System.out.println("Resultat = " + summe(zahl1, zahl2));
break;
case "-":
System.out.println("Resultat = " + differenz(zahl1, zahl2));
break;
case "*":
System.out.println("Resultat = " + produkt(zahl1, zahl2));
break;
case "/":
System.out.println("Resultat = " + quotientenwert(zahl1, zahl2));
break;
case "^":
System.out.println("Resultat = " + potenz(zahl1, zahl2));
break;
}
}
}
welche #?Mit Einrückung sollte es aussehen, wie eine Antwort darüber.
Wie geschrieben eine darüber: 109 - 1 = 108 => #108welche #?
Werde ich in Zukunft machen (ab jetzt).Wie geschrieben eine darüber: 109 - 1 = 108 => #108
Probier alle Rechenoperationen mit verschiedenen Eingabewerten aus. Wenn die Ergebnisse alle stimmen, dann wird das schon passen.Werde ich in Zukunft machen (ab jetzt).
aber ansonsten ist die Aufgabe jetzt als gelöst anzusehen?
int zahl1, zahl2;
String eingabe;
zahl1 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre erste Zahl ein:"));
zahl2 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre zweite Zahl ein:"));
eingabe = JOptionPane.showInputDialog("Tippen Sie das Rechenzeichen ein (+, -, *, /,^):");
int zahl1, zahl2;
zahl1 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre erste Zahl ein:"));
zahl2 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre zweite Zahl ein:"));
String operant;
operant = JOptionPane.showInputDialog("Tippen Sie das Rechenzeichen ein (+, -, *, /,^):");
// oder direkt
int zahl1 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre erste Zahl ein:"));
int zahl2 = Integer.parseInt(JOptionPane.showInputDialog("Tippen Sie Ihre zweite Zahl ein:"));
String operant = JOptionPane.showInputDialog("Tippen Sie das Rechenzeichen ein (+, -, *, /,^):");