सीधे मुख्य सामग्री पर जाएं

#28 How to make a Calculator in Java ? Java में Calculator कैसे बनायें ?

package com.sudhirtheindian2.java123;

import java.util.Scanner;

public class calculater {
public static void main(String[] args) {

// How to make a calculater in java language

int a,b,c,choice;
System.out.println("enter two number");
Scanner scanner = new Scanner(System.in);
System.out.println("enter your first number");
a=scanner.nextInt();
System.out.println("enter your second number");

b=scanner.nextInt();
System.out.println("enter your choice");
choice= scanner.nextInt();

switch (choice){
case 1:
c=a+b;
System.out.println("addition "+c);
break;
case 2:
c=a-b;
System.out.println("subtraction "+c);
break;
case 3:
c=a*b;
System.out.println("multiplication "+c);
break;

case 4:
c=a/b;
System.out.println("devide "+c);
break;
case 5:
c=a%b;
System.out.println("remainder "+c);
break;

default:
System.out.println("this is wrong choice");
break;





}




}
}

टिप्पणियाँ

इस ब्लॉग से लोकप्रिय पोस्ट