用安卓给我写个计算器代码
时间: 2023-02-28 09:01:28 浏览: 10
Android时写的一个计算器代码
我们可以使用Android的Android Studio来写一个计算器的代码。下面是一个简单的代码示例:public class Calculator { public static void main(String[] args) { int num1 = 2;
int num2 = 4; int sum = num1 + num2;
int difference = num1 - num2;
int product = num1 * num2;
int division = num1 / num2; System.out.println(num1 + "+" + num2 + "=" + sum);
System.out.println(num1 + "-" + num2 + "=" + difference);
System.out.println(num1 + "*" + num2 + "=" + product);
System.out.println(num1 + "/" + num2 + "=" + division);
}
}
阅读全文