Einfache Java-Rechner

Erstens dies ist keine Hausaufgaben Frage. Ich bin üben meine Kenntnisse über java. Ich dachte, ein guter Weg, dies zu tun ist, zu schreiben, ein einfaches Programm ohne Hilfe. Leider hat mein compiler sagt mir Fehler, die ich nicht wissen, wie Sie zu beheben. Ohne änderung viel Logik und den code, könnte mir jemand freundlicherweise zeigen, wo einige meiner Fehler? Dank

import java.lang.*;
import java.util.*;

public class Calculator
{
    private int solution;
    private int x;
    private int y;
    private char operators;

    public Calculator()
    {
        solution = 0;
        Scanner operators = new Scanner(System.in);
        Scanner operands = new Scanner(System.in);
    }

    public int addition(int x, int y)
    {
       return x + y;
    }
    public int subtraction(int x, int y)
    {
       return x - y;
    }
    public int multiplication(int x, int y)
    {    
       return x * y;
    }
    public int division(int x, int y)
    {
       solution = x / y;
       return solution;
    }
    public void main (String[] args)
    {
      System.out.println("What operation? ('+', '-', '*', '/')"); 

      System.out.println("Insert 2 numbers to be subtracted");
       System.out.println("operand 1: ");
       x = operands;
       System.out.println("operand 2: ");
       y = operands.next();
      switch(operators)
      {
          case('+'):
            addition(operands);
            operands.next();
            break;
          case('-'):
            subtraction(operands);
            operands.next();
            break;
          case('*'):
            multiplication(operands);
            operands.next();
            break;
          case('/'):
            division(operands);
            operands.next();
            break;
       }
  }
}
Welche Fehler sind Sie immer?
Vielen Dank für die Veröffentlichung Ihres Codes. Jedoch, es hilft auch, eine Menge, wenn man den text posten der Fehlermeldungen, die Sie bekommen, von der compiler - dies macht es einfacher für Menschen, um schnell das problem zu identifizieren (ohne Lesen Sie den gesamten code oder kompilieren Sie es selbst).

InformationsquelleAutor dukevin | 2010-04-29

Schreibe einen Kommentar