Show DevBest [JAVA] Simple Calculator [Command Line]

Hindi

System.out.println(" ");
Dec 30, 2012
989
192
As the title, Says;

Command line calculator written in java in about 10 minutes by me, here we go;

e22Q90M.png



PHP:
import java.util.Scanner;

class apples {
    public static void main(String args[])
    {
        int a,b;
        String c;
      
        Scanner choice = new Scanner(System.in);
      
        System.out.println("Operation Choices [Addition,Subtraction,Multiplication,Division] :: ");
        c = choice.nextLine();
      
        System.out.println("Number 1 ::");
        a =  choice.nextInt();
        System.out.println("Number 2 :: ");
        b = choice.nextInt();
      
        switch(c)
        {
        case "Addition":
            int d = a+b;
            System.out.printf("Addition of %d & %d is %d",a,b,d);
            break;
        case "Subtraction":
            int x = a-b;
            System.out.printf("Addition of %d & %d is %d",a,b,x);
            break;
        case "Multiplication":
            int y = a*b;
            System.out.printf("Addition of %d & %d is %d",a,b,y);
            break;
      
    case "Division":
        int z = a/b;
        System.out.printf("Addition of %d & %d is %d",a,b,z);
        break;
    default :
        System.out.println(" Enter a proper choice faggot!");
        break;
        }
    }
}

May not be that useful, But I thought it'd be nice to share it so yep.
 

Users who are viewing this thread

Top