Calculator with history I'm the newbie in Java (and programming) and I've tried to make a simple calculator. Code is barbaric, I know, so I would like to make it more beatiful.

Main.java:

import java.util.Scanner;
import java.util.Vector;

public class Main {
    static Main mainobject = new Main();
    ActionsToDo act = new ActionsToDo();
    Solution solve = new Solution();
    public static Vector&lt;Double&gt; v1 = new Vector&lt;Double&gt;();

    public void setValues(double fn, double sn) {
        solve.solveExpression(chooseOperator(), fn, sn);
        act.chooseAction(fn, sn);
    }

    public static double getFirstNumber() {
        System.out.println("Input the 1st number");
        Scanner sc = new Scanner(System.in);
        return sc.nextDouble();
    }

    public static double getSecondNumber() {
        System.out.println("Input the 2nd number");
        Scanner sc = new Scanner(System.in);
        return sc.nextDouble();
    }

    public char chooseOperator() {
        Scanner sc = new Scanner(System.in);
        System.out.println("What to do?" +
                "\n + for add" +
                "\n - for minus" +
                "\n * for multiply" +
                "\n / for divide" +
                "\n % for mod" +
                "\n ^ for first number into the power of second number");
        String operator = sc.next();
        return operator.charAt(0);
    }

    public static void main(String[] args) {
        mainobject.setValues(getFirstNumber(), getSecondNumber());
    }
}


Solution.java

public class Solution {
    static Main objectMain2 = new Main();
    public void solveExpression (char checker, double fn, double sn) {
        switch (checker) {
            case '+':
                System.out.println((fn + sn));
                objectMain2.v1.addElement((fn + sn));
                break;
            case '-':
                System.out.println((fn - sn));
                objectMain2.v1.addElement((fn - sn));
                break;
            case '*':
                System.out.println((fn * sn));
                objectMain2.v1.addElement((fn * sn));
                break;
            case '/':
                System.out.println((fn / sn));
                objectMain2.v1.addElement((fn / sn));
                break;
            case '%':
                System.out.println((fn % sn));
                objectMain2.v1.addElement((fn % sn));
                break;
            case '^':
                System.out.println(Math.pow(fn, sn));
                objectMain2.v1.addElement(Math.pow(fn,sn));
                break;
        }
    }
}


ActionsToDo.java:

import java.util.Scanner;
public class ActionsToDo {
    static Main objectMain = new Main();
    public void chooseAction(double fn, double sn) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Dormammu, I came to bargain! " +
                "Wanna do some extra calculations?" +
                "\n 1 - for 'Yes'" +
                "\n 2 - for 'No'" +
                "\n 3 - to change the numbers");
        int dormammu = sc.nextInt();
        switch (dormammu) {
            case 1:
                objectMain.setValues(fn, sn);
                break;
            case 2:
                System.out.println("Okay! Nobody misses you" +
                        "\n But here's the calculations you've done so far");
                for (int i = 0; i &lt; objectMain.v1.size();i++) {
                    System.out.print(objectMain.v1.get(i) + " ");
                }
                break;
            case 3:
                objectMain.setValues(objectMain.getFirstNumber(), objectMain.getSecondNumber());
                break;
            default:
                System.out.println("Shit, wrong answer,  you'll have to calculate " +
                        "with these numbers again and then you can do whatever you want");
                objectMain.setValues(fn, sn);

        }
    }
}


Note that the different classes are used just for training of using them
Glad you're taking on Java!

You should study Object Oriented Programming (OOP), which is core in Java, a little bit more to use classes in a more suitable and efficient way.

The general rule of a class is "one class one purpose" which it looks like you're trying to apply, but since you don't have any objects, it becomes a bit arbitrary.

An example would be to have a class called Calcualtor that has functions for what a calculator could do, then you could have another class called InputHandler that handles the reading from the user interface (in this case that's the terminal). It's very bad to call the Main class in all classes, it's very backwards, main is supposed to handle the other classes and there's only one Main.

Because of the structure you have here you notice that you find yourself using static a lot, we call this "static overuse". If you apply OOP properly you won't need static unless there's an intended use, like a variable that never changes and is the same for all objects of that type.

You should be fine by just rearranging your methods into objects and call them from main:

public class Main {
    public static void main(String[] args) {
        InputHandler inputHandler = new InputHandler();
        inputHandler.start();
    }
}


Input Handler:

public class InputHandler {
    /* Notice how I put the calculator and scanner up in the 
       object-scope, you can now re-use them throughout this object.
    */
    private Calculator calculator = new Calculator();
    private Scanner sc = new Scanner(System.in);
    private boolean keepOn = true;

    public void start() {
        System.out.println("Welcome to my calculator!");
        performAction(1);  // This is what we call a magic number. Don't do this, instead you could make variables for the options, or, you could make an enum.
        while(keepOn == true) {
            calculate();
        }
    }

    public void calculate() {
       int action = selectAction();
       performAction(action);
    }

    public double getFirstNumber() {
        System.out.println("Input the 1st number");
        return sc.nextDouble();
    }

    public double getSecondNumber() {
        System.out.println("Input the 2nd number");
        return sc.nextDouble();
    }

    public char chooseOperator() {
        System.out.println("What to do?" +
                "\n + for add" +
                "\n - for minus" +
                "\n * for multiply" +
                "\n / for divide" +
                "\n % for mod" +
                "\n ^ for first number into the power of second number");

        String operator = sc.next();
        return operator.charAt(0);
    }

    public int selectAction() {
        System.out.println("Dormammu, I came to bargain! " +
                "Wanna do some extra calculations?" +
                "\n 1 - for 'Yes'" +
                "\n 2 - for 'No'");
        int dormammu = sc.nextInt();
        return dormammu;
    }

    public double performCalculation() {
        char operand = chooseOperator();
        double firstNumber = getFirstNumber();
        double secondNumber = getSecondNumber();
        double result = calculator.calculate(firstNumber, secondNumber, operand);
        System.out.println("The result of " + firstNumber + operand + secondNumber + "is: " + result);
        return result;
    }

    public void performAction(int action) {
        switch (action) {
            case 1:
                performCalculation();
                break;
            case 2:
                System.out.println("Okay! Nobody misses you" +
                        "\n But here's the calculations you've done so far");
                for (int i = 0; i &lt; calculator.calculations.size(); i++) {
                    System.out.println(calculator.calculations.get(i));
                }
                keepOn = false;
                break;
            default:
                System.out.println("Shit, wrong answer, try again!");
                calculate();
        }
    }
}


And the calculator:

public class Calculator {
    public Vector&lt;Double&gt; calculations = new Vector&lt;&gt;();

    public double calculate(double firstNumber, double secondNumber, char operand) {
        switch (operand) {
            case '+':
                calculations.addElement((firstNumber + secondNumber));
                return firstNumber + secondNumber;
            case '-':
                calculations.addElement((firstNumber - secondNumber));
                return firstNumber - secondNumber;
            case '*':
                calculations.addElement((firstNumber * secondNumber));
                return firstNumber * secondNumber;
            case '/':
                calculations.addElement((firstNumber / secondNumber));
                return firstNumber / secondNumber;
            case '%':
                calculations.addElement((firstNumber % secondNumber));
                return firstNumber % secondNumber;
            case '^':
                calculations.addElement(Math.pow(firstNumber, secondNumber));
                return Math.pow(firstNumber, secondNumber);
            default:
                System.out.println("Oops! Received an operand that's not supported! How'd that happen?");
                throw new UnsupportedOperationException();
        }
    }
}


This is just a small refactoring of your code. You should always treat user input with great care and use try-catch to make sure the input is what you expect. Your application will crash if you type no instead of 2.

Also notice how I used some recursion in performAction(int action) where if you do not get the expected answer it re-attempts to do the calculation. This however only works if the other answer is a digit. I'd recommend you try to read a String and then try to convert it to an int using Integer.valueOf("1") and catch errors if it's not a number.