I wanted to make a calculator that is capable to do code with 2,3 or 4 values.
e.g.1 + 2 * 3 -4 or 1 + 2 -3
This the code I made:
import java.util.*;
public class LoopCalc {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("How many values do you like (2, 3, or 4):");
int values = scan.nextInt();
double[] num = new double[values];
for (int i = 0; i < num.length; i++) {
System.out.println("Enter value " + (i + 1) + ":");
double value = scan.nextDouble();
num[i] = value;
}
}
}
I do not know what to do next and I do not want to use too much case and if/else statements.