java cli calculator

date: 16/11/2024

language: java

utility: calculator

Terrible CLI calculator in java i made for school

	import java.util.Scanner;

public static void main(String[] args) {
    
int s = 0;
int v = 0;

Scanner sc = new Scanner(System.in);
    System.out.println("First number");
        int n1 = sc.nextInt();
    System.out.println("Operation : 1) + 2) - 3) * 4) /");
        int o = sc.nextInt();
    System.out.println("Second number");
        int n2 = sc.nextInt();

    if(o==1){
        s = n1 + n2;
    } else {
        if(o==2){
            s = n1 - n2;
        } else {
            if(o==3){
                s = n1 * n2;
            } else {
                s = n1 / n2;
            };
        };
    };

    System.out.println("The current sum is " + s);
    
    System.out.println("Do another operation on the sum? 1) Yes 2) No");
        v = sc.nextInt();

while(v==1) {
    


        System.out.println("Operation : 1) + 2) - 3) * 4) /");
            o = sc.nextInt();
        System.out.println("Number");
            int n = sc.nextInt();

    if(o==1){
        s = s + n;
    } else {
        if(o==2){
            s = s - n;
        } else {
            if(o==3){
                s = s * n;
            } else {
                s = s / n;
                };
            };
        };

    System.out.println("The current sum is " + s);

    System.out.println("Do another operation on the sum? 1) Yes 2) No");
        v = sc.nextInt();

};

    System.out.println("The final sum is " + s);
};