Answer the question
In order to leave comments, you need to log in
How to cast an integer to double and then divide it?
Hi guys. I have a task to write a simple calculator that counts two numbers.
package Dz;
import java.util.Scanner;
public class SimpleCalculator {
public static void main(String[] args) {
try(Scanner dev = new Scanner(System.in)) {
int a, b, c, max, min;
double e;
System.out.println("Pleasee enter number A");
a = dev.nextInt();
System.out.println("Pleasee enter number B");
b = dev.nextInt();
System.out.println("a = "+a);
System.out.println("b = "+b);
c = a + b;
System.out.println("a + b = "+c);
c = a - b;
System.out.println("a - b = "+c);
c = a * b;
System.out.println("a * b = " +c);
c = a / b;
System.out.println("a/b = " +e); // double
e = a / b; //double
System.out.println("a / b = " +c);
c = a % b;
System.out.println("a % b = " +c);
c = a ^ b;
System.out.println("a ^ b = " +c);
}
}
}
Answer the question
In order to leave comments, you need to log in
System.out.println("a/b = " +e); // double
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question