Question #3558

(1) Write a program to perform all arithmetic operators on the following variables a=5, b=10?

Expert's answer

public class Arifmetic {

public static void main(String[] args){

& int a = 5;

& int b = 10;

& int plus = a+b;

& int minus = a-b;

& int mult = a*b;

& double div = (double) a/b;

& System.out.println(a+" + "+b+" = "+plus);

& System.out.println(a+" - "+b+" = "+minus);

& System.out.println(a+" * "+b+" = "+mult);

& System.out.println(a+" / "+b+" = "+div);

}

}

public static void main(String[] args){

& int a = 5;

& int b = 10;

& int plus = a+b;

& int minus = a-b;

& int mult = a*b;

& double div = (double) a/b;

& System.out.println(a+" + "+b+" = "+plus);

& System.out.println(a+" - "+b+" = "+minus);

& System.out.println(a+" * "+b+" = "+mult);

& System.out.println(a+" / "+b+" = "+div);

}

}

## Comments

## Leave a comment