题目
根据JAVA用户输入两个整数,分别输出这两个数的和、差、积、商.
提问时间:2020-12-20
答案
import java.util.Scanner;
public class putin
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println("现在可以输入一个数字.整数或者是小数:");
int i = 0;
int x = 0;
int y = 0;
while(s.hasNext())
{
i++;
if( 1 == i)
{
x = s.nextInt();
}
if( 2 == i)
{
y = s.nextInt();
System.out.println("加法:"+(x+y));
System.out.println("减法:"+(x-y));
System.out.println("乘法:"+(x*y));
System.out.println("除法:"+((double)x/(double)y));
}
}
}
}
你可能不知道怎么用Scanner
看你不会的份上 我给你写出一个!
public class putin
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println("现在可以输入一个数字.整数或者是小数:");
int i = 0;
int x = 0;
int y = 0;
while(s.hasNext())
{
i++;
if( 1 == i)
{
x = s.nextInt();
}
if( 2 == i)
{
y = s.nextInt();
System.out.println("加法:"+(x+y));
System.out.println("减法:"+(x-y));
System.out.println("乘法:"+(x*y));
System.out.println("除法:"+((double)x/(double)y));
}
}
}
}
你可能不知道怎么用Scanner
看你不会的份上 我给你写出一个!
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1不等式log3(-x)>x+1的解集为
- 2在化工产品中哪些属于有机化学制品?
- 32cos^2(α)-1的值是多少; 最好是有详细的演算过程.
- 4为什么有一种动物叫恐龙
- 5I negotiate the transference!The bank cost is of U$S 170 only to send U$S 80.!请帮忙
- 6使某一沉淀溶解的必要条件是(Ip<Ksp)?是什么意思
- 7求问空间向量的数量积,模长公式以及垂直的判定公式
- 8hurry up 什么词性
- 9what has the 2010 espo brought to china and the world
- 10将一张长62.8cm,宽12.56cm的长方形硬纸围成一个圆柱.当高是62.8cm,圆柱的底面积是多少
热门考点
- 10、0、7、6、写出读两个‘’零〃的两住小数?
- 2在三角形ABC中B(-6.0)C(6.0)直线ABAC的斜率为9/4则顶点A的轨迹
- 3北京到呼和浩特的铁路线长660千米,一列火车从呼和浩特开出,每小时行驶48千米;另一列火车从北京开出,每小时行驶72千米.两列火车同时开出,相向而行,经过几时相遇?
- 4有关机械能`
- 5英语翻译:“不用客气,尝一尝吧(你要尝一尝吗?)”,
- 6苹果比梨多五分之一,梨就比苹果少五分之一,对还是错
- 7定积分∫sint/t dt 上限是无穷,下限是零.
- 8等差数列{an}的前n项和为Sn,且a8+a16=0,则有:
- 9Oh,you look handsome in this suit,Peter.The tie also ---- your suit very well.选项在问题补充里
- 10描写美好心灵的作文