计算机二级考试Java模拟试题及答案2017
来源:才华咖 本文已影响1.57W人
来源:才华咖 本文已影响1.57W人
不积跬步,何以至千里。试题的规律都是从一点一滴积累而来。下面是小编整理的计算机二级的文章" target="_blank" >计算机二级考试Java模拟试题及答案,欢迎练习!
1、编写程序,计算下列分段函数的值。
x? (x>=0)
y=
-x? (x<0)
import .*;
public class testa
{ public static void main(String[] args) throws IOException
{
float? x,y;
InputStreamReader reader=new InputStreamReader();
BufferedReader input=new BufferedReader(reader);
tln("请输入x:");
String temp=Line();
x = eFloat(temp);
if(x>=0)
{
y=x;
}else
{
y=-x;
}
tln("y="+y);
}
}
2、根据年龄,判断某人是否为成年。
import .*;
public class testa
{
public static void main(String[] args) throws IOException
{
int x;
InputStreamReader reader=new InputStreamReader();
BufferedReader input=new BufferedReader(reader);
tln("请输入x:");
String temp=Line();
x = eFloat(temp);
if(x>=18)
{
tln("成年人");
}
if(x<18)
{
tln("未成年");
}
}
}
3、判断2020的奇偶性,并进行输出。
public class test
{
public static void main(String[] args)
{
int x;
x=2020;
if(x%2==0)
tln(+x+"是偶数");
else
tln(+x+"不是偶数");
}
}
4、比较两个数的`大小,找出其中的最大数并输出。
import .*;
public class ka
{ public static void main(String[] args) throws IOException
{
float? x,y,m;
m=0;
InputStreamReader readerx=new InputStreamReader();
BufferedReader inputx=new BufferedReader(readerx);
tln("请输入x:");
String tempx=Line();
x = eFloat(tempx);
InputStreamReader readery=new InputStreamReader();
BufferedReader inputy=new BufferedReader(readery);
tln("请输入y:");
String tempy=Line();
y= eFloat(tempy);
if(x>y)
{
m=x;
}else
{
m=y;
}
tln("最大数为"+m);
}
}
5、比较两个数的大小,找出其中的最小数并输出。
import .*;
public class ka
{ public static void main(String[] args) throws IOException
{
float? x,y,m;
m=0;
InputStreamReader readerx=new InputStreamReader();
BufferedReader inputx=new BufferedReader(readerx);
tln("请输入x:");
String tempx=Line();
x = eFloat(tempx);
InputStreamReader readery=new InputStreamReader();
BufferedReader inputy=new BufferedReader(readery);
tln("请输入y:");
String tempy=Line();
y= eFloat(tempy);
if(x{
m=x;
}else
{
m=y;
}
tln("最小数为"+m);
}
}
6、编写一个Java程序,判断某年份是否为闰年。
import .*;
public class testa
{
public static void main(String[] args) throws IOException
{
float? x;
InputStreamReader reader=new InputStreamReader();
BufferedReader input=new BufferedReader(reader);
tln("请输入x:");
String temp=Line();
x =eFloat(temp);
if(x@0==0)
{
tln(+x+"是闰年");
}
else
if(x%4==0)
{
tln(+x+"是闰年");
}
else{ tln(+x+"不是闰年");}
}
}
7、比较两个数的大小,找出其中的最大数和最小数并输出。
import .*;
public class ka
{ public static void main(String[] args) throws IOException
{
float? x,y;
InputStreamReader readerx=new InputStreamReader();
BufferedReader inputx=new BufferedReader(readerx);
tln("请输入x:");
String tempx=Line();
x = eFloat(tempx);
InputStreamReader readery=new InputStreamReader();
BufferedReader inputy=new BufferedReader(readery);
tln("请输入y:");
String tempy=Line();
y= eFloat(tempy);
if(x{
tln("最小数为"+x);
tln("最大数为"+y);
}else
{
tln("最小数为"+y);
tln("最大数为"+x);
}
}
}
8、比较两个数的大小,找出其中的最大数和最小数,并输出最大数和最小数之差。
import .*;
public class ka
{ public static void main(String[] args) throws IOException
{
float? x,y,m;
InputStreamReader readerx=new InputStreamReader();
BufferedReader inputx=new BufferedReader(readerx);
tln("请输入x:");
String tempx=Line();
x = eFloat(tempx);
InputStreamReader readery=new InputStreamReader();
BufferedReader inputy=new BufferedReader(readery);
tln("请输入y:");
String tempy=Line();
y= eFloat(tempy);
if(x{
tln("最小数为"+x);
tln("最大数为"+y);
m=y-x;
tln("最大数与最小数之差为"+m);
}else
{
tln("最小数为"+y);
tln("最大数为"+x);
m=x-y;
tln("最大数与最小数之差为"+m);
}
}
}
9、编写程序,计算下列分段函数的值。
x? (x>0)
y=???? 0? (x=0)
-x? (x<0)
import .*;
public class testa
{
public static void main(String[] args) throws IOException
{
float? x,y;
y=0;
InputStreamReader reader=new InputStreamReader();
BufferedReader input=new BufferedReader(reader);
tln("请输入x:");
String temp=Line();
x = eFloat(temp);
if(x>0)
{
y=x;
}
if(x==0)
{
y=0;
}
if(x<0)
{
y=-x;
}
tln("y="+y);
}
}
10、编写程序,计算下列分段函数的值。
x-1? (x>1)
y=???? 0? (-1≤x≤1)
x+10? (x<-1)
import .*;
public class testa
{
public static void main(String[] args) throws IOException
{
float? x,y;
y=0;
InputStreamReader reader=new InputStreamReader();
BufferedReader input=new BufferedReader(reader);
tln("请输入x:");
String temp=Line();
x = eFloat(temp);
if(x>1)
{
y=x-1;
}
if(1.0>=x&&x>=-1.0)
{
y=0;
}
if(x<-1)
{
y=x+10;
}
tln("y="+y);
}
}
2016计算机二级java考试上机模拟试题及答案
计算机考试Java模拟试题及答案2017
2015年计算机二级考试JAVA模拟试题库(二)答案及解析
2015年全国计算机二级考试Java模拟试题(二)答案及解析
全国计算机二级考试Java模拟试题答案及解析
2015年计算机二级考试JAVA模拟试题库(一)答案及解析
计算机二级JAVA考试模拟试题及答案
2016年计算机二级JAVA模拟试题及答案
2017计算机二级考试JAVA上机试题及答案
2016年9月计算机二级Java模拟试题及答案
2017年计算机二级考试java模拟题(含答案)
2017年3月计算机二级JAVA临考模拟试题与答案
2016下半年计算机二级Java模拟试题及答案
2015下半年全国计算机二级Java考试模拟题及答案
2017年计算机二级Java模拟试题及答案
计算机二级JAVA上机试题及答案2017
2017计算机二级《JAVA》考前测试题及答案
JAVA计算机二级上机试题及答案2017
2017年计算机二级Java模拟试题及答案
73月计算机二级JAVA临考模拟试题与答案
计算机二级Java考试及答案2017
2017年9月计算机二级JAVA考试模拟试题
2017年Java计算机考试模拟试题附答案
2017年9月计算机二级JAVA考试题及答案
2017计算机二级考试Java练习题及答案
2017年9月计算机二级考试JAVA考试题及答案
2016年计算机二级JAVA考试试题及答案
计算机二级考试《java》试题及答案
2016计算机二级考试Java试题及答案
全国计算机二级考试Java模拟试题(一)答案及解析
2017年计算机二级考试JAVA冲刺试题及答案大纲
2017计算机等级考试二级java笔试套题及答案
2017年49次计算机二级Java考试试题及答案
2017年9月计算机二级JAVA考试基础试题及答案
考试试题及答案参考
2016计算机二级java考试上机试题及答案
2017年计算机二级考试Java练习题及答案
计算机二级考试真题以及答案
2017下半年计算机二级考试《java》试题及答案
2017计算机二级Java备考冲刺试题及答案