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

#27 What is operator in Java ? Arithmetic Operator with Calculator's example

package com.sudhirtheindian2.java123;

import java.util.Scanner;

public class arithmetic_operator {
public static void main(String[] args) {
// What is operator and arithmetic operator with calculater example

// operator
// operator is a symbol that is used to perform
// operatons according to user requirement

// types of operator

// arithmetic_operator
// relational oprator
// logical operator


// arithmetic operator example

int a,b,c,choice;
System.out.println("enter the two number");
Scanner scanner = new Scanner(System.in);
a= scanner.nextInt();
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("multiply"+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 please choose right");
break;


}


}
}

टिप्पणियाँ

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