麻烦大家帮我编一道JAVA程序题! 感激不尽!!!
请用Eclipse编写代码,完成以下题目。1.从控制台输入两个整数数,输出两个数加、减、乘、除、取余的结果...
请用Eclipse编写代码,完成以下题目。 1. 从控制台输入两个整数数,输出两个数加、减、乘、除、取余的结果
展开
4个回答
展开全部
Scanner scan = new Scanner(System.in);
System.out.println("请输入第一个整数:");
int num1 = scan.nextInt();
System.out.println("请输入第二个整数:");
int num2 = scan.nextInt();
System.out.println("num1 = "+num1);
System.out.println("num2 = "+num2);
System.out.println("num1 + num2 = "+(num1+num2));
System.out.println("num1 - num2 = "+(num1-num2));
System.out.println("num1 * num2 = "+(num1*num2));
System.out.println("num1 / num2 = "+(num1/num2));
System.out.println("num1 % num2 = "+(num1%num2));
System.out.println("请输入第一个整数:");
int num1 = scan.nextInt();
System.out.println("请输入第二个整数:");
int num2 = scan.nextInt();
System.out.println("num1 = "+num1);
System.out.println("num2 = "+num2);
System.out.println("num1 + num2 = "+(num1+num2));
System.out.println("num1 - num2 = "+(num1-num2));
System.out.println("num1 * num2 = "+(num1*num2));
System.out.println("num1 / num2 = "+(num1/num2));
System.out.println("num1 % num2 = "+(num1%num2));
展开全部
import java.util.Scanner;
public class Caculate {
public static void main(String[] args) {
int num1, num2, sum, minus, times, divis, remain;
System.out.println("请输入第一个整数:");
Scanner input1 = new Scanner(System.in);
num1 = input1.nextInt();
System.out.println("请输入第二个整数:");
Scanner input2 = new Scanner(System.in);
num2 = input2.nextInt();
sum = num1 + num2;
minus = num1 - num2;
times = num1 * num2;
divis = num1 / num2;
remain = num1 % num2;
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
System.out.println("num1 + num2 = " + sum);
System.out.println("num1 - num2 = " + minus);
System.out.println("num1 * num2 = " + times);
System.out.println("num1 / num2 = " + divis);
System.out.println("num1 % num2 = " + remain);
}
}
public class Caculate {
public static void main(String[] args) {
int num1, num2, sum, minus, times, divis, remain;
System.out.println("请输入第一个整数:");
Scanner input1 = new Scanner(System.in);
num1 = input1.nextInt();
System.out.println("请输入第二个整数:");
Scanner input2 = new Scanner(System.in);
num2 = input2.nextInt();
sum = num1 + num2;
minus = num1 - num2;
times = num1 * num2;
divis = num1 / num2;
remain = num1 % num2;
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
System.out.println("num1 + num2 = " + sum);
System.out.println("num1 - num2 = " + minus);
System.out.println("num1 * num2 = " + times);
System.out.println("num1 / num2 = " + divis);
System.out.println("num1 % num2 = " + remain);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
...这么简单不自己写!你这不已经实现了吗? 都在控制台打印出来了~~~
追问
我要代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-11-16
展开全部
真真的太简单了,连个判断都差不多不用写
追问
那你帮我写这段代码呗,我正在考试呢 急用啊!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询