import java.util.Scanner; public class Main2 { public static void main(String[] args) { int choice,firstnum,secondnum; Scanner sc = new Scanner(System.in); while(true) { System.out.println("=================================="); System.out.println(" S E L E C T O P E R A T I O N"); System.out.println("=================================="); System.out.println(" [1] --> Computation of Power"); System.out.println("----------------------------------"); System.out.println("Enter choice:"); choice = sc.nextInt(); System.out.println("Enter first number:"); firstnum = sc.nextInt(); System.out.println("Enter second number:"); secondnum = sc.nextInt(); } else if(choice == 1){ System.out.println("Result: "+(firstnum/secondnum)); }
firstnum
secondnum
secondnum > firstnum
0
Quote:System.out.println("Result: "+(firstnum/secondnum));
Quote:This is a binary operator that is used to divide the first operand(dividend) by the second operand(divisor) and give the quotient as result.
Quote:first number: 2, second number:10 and results is 0 why?
((double)firstnum/secondnum)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)