java语言 百分网手机站

计算机语言Java考试模拟试题附答案

时间:2020-11-12 14:39:43 java语言 我要投稿

计算机语言Java考试模拟试题附答案

  科学的未来只能是属于勤奋而又谦虚的年轻一代!以下是小编为大家搜索整理的计算机语言Java考试模拟试题附答案,希望能给大家带来帮助!更多精彩内容请及时关注我们应届毕业生考试网!

  1、编写程序,计算下列分段函数的值。

  x? (x>=0)

  y=

  -x? (x<0)

  import java.io.*;

  public class testa

  { public static void main(String[] args) throws IOException

  {

  float? x,y;

  InputStreamReader reader=new InputStreamReader(System.in);

  BufferedReader input=new BufferedReader(reader);

  System.out.println("请输入x:");

  String temp=input.readLine();

  x = Float.parseFloat(temp);

  if(x>=0)

  {

  y=x;

  }else

  {

  y=-x;

  }

  System.out.println("y="+y);

  }

  }

  2、根据年龄,判断某人是否为成年。

  import java.io.*;

  public class testa

  {

  public static void main(String[] args) throws IOException

  {

  int x;

  InputStreamReader reader=new InputStreamReader(System.in);

  BufferedReader input=new BufferedReader(reader);

  System.out.println("请输入x:");

  String temp=input.readLine();

  x = Float.parseFloat(temp);

  if(x>=18)

  {

  System.out.println("成年人");

  }

  if(x<18)

  {

  System.out.println("未成年");

  }

  }

  }

  3、判断2020的奇偶性,并进行输出。

  public class test

  {

  public static void main(String[] args)

  {

  int x;

  x=2020;

  if(x%2==0)

  System.out.println(+x+"是偶数");

  else

  System.out.println(+x+"不是偶数");

  }

  }

  4、比较两个数的大小,找出其中的最大数并输出。

  import java.io.*;

  public class ka

  { public static void main(String[] args) throws IOException

  {

  float? x,y,m;

  m=0;

  InputStreamReader readerx=new InputStreamReader(System.in);

  BufferedReader inputx=new BufferedReader(readerx);

  System.out.println("请输入x:");

  String tempx=inputx.readLine();

  x = Float.parseFloat(tempx);

  InputStreamReader readery=new InputStreamReader(System.in);

  BufferedReader inputy=new BufferedReader(readery);

  System.out.println("请输入y:");

  String tempy=inputy.readLine();

  y= Float.parseFloat(tempy);

  if(x>y)

  {

  m=x;

  }else

  {

  m=y;

  }

  System.out.println("最大数为"+m);

  }

  }

  5、比较两个数的.大小,找出其中的最小数并输出。

  import java.io.*;

  public class ka

  { public static void main(String[] args) throws IOException

  {

  float? x,y,m;

  m=0;

  InputStreamReader readerx=new InputStreamReader(System.in);

  BufferedReader inputx=new BufferedReader(readerx);

  System.out.println("请输入x:");

  String tempx=inputx.readLine();

  x = Float.parseFloat(tempx);

  InputStreamReader readery=new InputStreamReader(System.in);

  BufferedReader inputy=new BufferedReader(readery);

  System.out.println("请输入y:");

  String tempy=inputy.readLine();

  y= Float.parseFloat(tempy);

  if(x{

  m=x;

  }else

  {

  m=y;

  }

  System.out.println("最小数为"+m);

  }

  }

  6、编写一个Java程序,判断某年份是否为闰年。

  import java.io.*;

  public class testa

  {

  public static void main(String[] args) throws IOException

  {

  float? x;

  InputStreamReader reader=new InputStreamReader(System.in);

  BufferedReader input=new BufferedReader(reader);

  System.out.println("请输入x:");

  String temp=input.readLine();

  x =Float.parseFloat(temp);

  if(x@0==0)

  {

  System.out.println(+x+"是闰年");

  }

  else

  if(x%4==0)

  {

  System.out.println(+x+"是闰年");

  }

  else{ System.out.println(+x+"不是闰年");}

  }

  }

  7、比较两个数的大小,找出其中的最大数和最小数并输出。

  import java.io.*;

  public class ka

  { public static void main(String[] args) throws IOException

  {

  float? x,y;

  InputStreamReader readerx=new InputStreamReader(System.in);

  BufferedReader inputx=new BufferedReader(readerx);

  System.out.println("请输入x:");

  String tempx=inputx.readLine();

  x = Float.parseFloat(tempx);

  InputStreamReader readery=new InputStreamReader(System.in);

  BufferedReader inputy=new BufferedReader(readery);

  System.out.println("请输入y:");

  String tempy=inputy.readLine();

  y= Float.parseFloat(tempy);

  if(x{

  System.out.println("最小数为"+x);

  System.out.println("最大数为"+y);

  }else

  {

  System.out.println("最小数为"+y);

  System.out.println("最大数为"+x);

  }

  }

  }

  8、比较两个数的大小,找出其中的最大数和最小数,并输出最大数和最小数之差。

  import java.io.*;

  public class ka

  { public static void main(String[] args) throws IOException

  {

  float? x,y,m;

  InputStreamReader readerx=new InputStreamReader(System.in);

  BufferedReader inputx=new BufferedReader(readerx);

  System.out.println("请输入x:");

  String tempx=inputx.readLine();

  x = Float.parseFloat(tempx);

  InputStreamReader readery=new InputStreamReader(System.in);

  BufferedReader inputy=new BufferedReader(readery);

  System.out.println("请输入y:");

  String tempy=inputy.readLine();

  y= Float.parseFloat(tempy);

  if(x{

  System.out.println("最小数为"+x);

  System.out.println("最大数为"+y);

【计算机语言Java考试模拟试题附答案】相关文章:

1.全国计算机考试二级考试Java模拟试题附答案

2.税务师考试模拟试题目(附答案)

3.2017年托福阅读考试模拟试题附答案

4.Java考试在线模拟测试试题

5.计算机java考试模拟试题

6.《人力资源》模拟试题(附答案)

7.2017税务师考试《税法一》模拟试题(附答案)

8.2017年雅思考试阅读模拟试题附答案

9.计算机二级Java备考试题附答案