奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

試題

9月計算機二級考試JAVA考試題及答案

時間:2024-08-02 11:38:29 試題 我要投稿

2017年9月計算機二級考試JAVA考試題及答案

  2017年下半年計算機二級考試正在備考中。你知道計算機二級考試JAVA科目都考哪些知識嗎?為了方便考生備考計算機二級考試JAVA 科目。下面是小編為大家帶來的計算機二級考試JAVA考試題,歡迎閱讀。

2017年9月計算機二級考試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);

  m=y-x;

  System.out.println("最大數與最小數之差為"+m);

  }else

  {

  System.out.println("最小數為"+y);

  System.out.println("最大數為"+x);

  m=x-y;

  System.out.println("最大數與最小數之差為"+m);

  }

  }

  }

  9、編寫程序,計算下列分段函數的值。

  x? (x>0)

  y=???? 0? (x=0)

  -x? (x<0)

  import java.io.*;

  public class testa

  {

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

  {

  float? x,y;

  y=0;

  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;

  }

  if(x==0)

  {

  y=0;

  }

  if(x<0)

  {

  y=-x;

  }

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

  }

  }

  10、編寫程序,計算下列分段函數的值。

  x-1? (x>1)

  y=???? 0? (-1≤x≤1)

  x+10? (x<-1)

  import java.io.*;

  public class testa

  {

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

  {

  float? x,y;

  y=0;

  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>1)

  {

  y=x-1;

  }

  if(1.0>=x&&x>=-1.0)

  {

  y=0;

  }

  if(x<-1)

  {

  y=x+10;

  }

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

  }

  }

  考試題二:

  1、 編寫程序,實現1到100之間整數的累加并輸出運算結果。

  public class a

  {

  public static void main(String[] args)

  {

  int i,s=0;

  for(i=1;i<=100;i++)

  {

  s=s+i;

  }

  System.out.println("1到100的累加和是"+s);

  }}

  2、編寫程序,計算1~100中奇數的累加和并輸出。

  public class a

  {

  public static void main(String[] args)

  {

  int i,s=0;

  for(i=1;i<=100;i++)

  {

  if(i%2!=0)

  s=s+i;

  }

  System.out.println("1到100的奇數累加和是"+s);

  }}

  3、編寫程序,計算1~100中偶數的累加和并輸出。

  public class a

  {

  public static void main(String[] args)

  {

  int i,s=0;

  for(i=1;i<=100;i++)

  {

  if(i%2==0)

  s=s+i;

  }

  System.out.println("1到100的偶數累加和是"+s);

  }}

  4、編寫程序,計算10的階乘并輸出運算結果。

  public class a

  {

  public static void main(String[] args)

  {

  int i,s=1;

  for(i=1;i<=10;i++)

  {

  s=s*i;

  }

  System.out.println("10的階乘是"+s);

  }}

  5、編寫程序,計算1、2、3...的累加和,條件是和小于50。

  public class a

  {

  public static void main(String[] args)

  {

  int i=1,s=0;

  label:

  while(true)

  {? s=s+i;

  i++;

  if(s>50)

  { s=s+1-i;

  break;}}

  System.out.println("從1開始的累加和小于50的累加和是"+s);

  }}

  6、編寫程序,計算偶數2、4、6...的累加和,條件是和小于50。

  public class a

  {

  public static void main(String[] args)

  {

  int i=1,s=0;

  label:

  while(true)

  {? s=s+2*i;

  i++;

  if(s>50)

  { s=s-2*i+2*1;

  break;}}

  System.out.println("從2開始的偶數累加和小于50的累加和是"+s);

  }}

  7、編寫程序,輸出下列圖案:

  *

  ***

  *****

  *******

  public class a

  {???????? public static void main(String[] args)

  { int i,k;

  for(i=1;i<=4;i++)

  {

  for(k=1;k<=2*i-1;k++)

  System.out.print("*");

  System.out.println();

  }

  }

  }

  8、編寫程序,輸出下列圖案:

  *

  ***

  *****

  *******

  public class a

  {???????? public static void main(String[] args)

  { int i,j,k;

  for(i=1;i<=4;i++)

  {

  for(j=1;j<=8-2*i;j++)

  System.out.print(" ");

  for(k=1;k<=2*i-1;k++)

  System.out.print("*");

  System.out.println();

  }

  }

  }

  9、編寫程序,輸出下列圖案:

  *******

  *****

  ***

  *

  public class a

  {???????? public static void main(String[] args)

  { int i,j,k;

  for(i=1;i<=4;i++)

  {

  for(j=1;j<=2*i-2;j++)

  System.out.print(" ");

  for(k=1;k<=9-2*i;k++)

  System.out.print("*");

  System.out.println();

  }

  }

  }

  10、編寫程序在終端打印1~100之間的素數。

  public class a

  {???????? public static void main(String[] args)

  { int i,j;

  label:

  for(i=2;i<=100;i++)

  {????? for(j=2;jif(i%j==0)

  continue label;

  System.out.print(+i);

  System.out.println();

  }

  }

  }

  11、編寫一個java程序,用窮舉法找出2~50之間的素數,并打印出來。

  public class s{

  public static void main(String args[]){

  int i,j,k ;

  boolean flag ;

  for (i=2;i<=50 ;i++ ){

  flag =true ;

  k=i/2 ;

  for (j=2;j<=k ;j++ ){

  if (i%j==0){

  flag = false ;

  break ;

  }

  }

  if (flag){

  System.out.println(i+"") ;

  }

  }

  }

  }

  12、編寫一自定義方法,找出兩個數中的最大數,并main方法中驗證。

  public class a

  {

  static double Max(double x,double y)

  {?? double t;

  if(x>=y)

  {

  t=x;

  }else

  { t=y;???? }

  return t;

  }

  public static void main(String[] args)

  {

  double x,y,m;

  x=549.265;

  y=56.28;

  m =Max(x,y);

  System.out.println("最大數是"+m);

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

  if(m>=x&&y<=m)

  {

  System.out.println("ture");

  }

  else

  {

  System.out.println("flase");

  }

  }

  }

  13、編寫一自定義方法,找出兩個數中的最小數,并main方法中驗證。

  public class a

  {

  static double Min(double x,double y)

  {?? double t;

  if(x<=y)

  {

  t=x;

  }else

  { t=y;???? }

  return t;

  }

  public static void main(String[] args)

  {

  double x,y,m;

  x=245.38;

  y=525.63;

  m =Min(x,y);

  System.out.println("最小數是"+m);

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

  if(m<=x&&y>=m)

  {

  System.out.println("ture");

  }

  else

  {

  System.out.println("flase");

  }

  }

  }

  14、編程,找出長度為10的數組中,數組元素的最大值,并輸出。

  public class a

  {

  public static void main(String[] args)

  {

  double x[]={25.3,56.3,15.3,125.25,465.36,456.32,458.21,456.325,4856.3215,41.6};

  double m= x[0];

  int i;

  for(i=0;i<10;i++)

  { if (m<=x[i])

  m=x[i];

  }

  System.out.println("最大數是"+m); }}

  15、編程,找出長度為10的數組中,數組元素的最小值,并輸出。

  public class a

  {

  public static void main(String[] args)

  {

  double x[]={25.3,56.3,15.3,125.25,465.36,456.32,458.21,456.325,4856.3215,41.6};

  double m=x[0];

  int i;

  for(i=0;i<10;i++)

  { if (m>=x[i])

  m=x[i];

  }

  System.out.println("最小數是"+m); }}

  16、編程,找出長度為10的數組中,數組元素的最大值和最小值,并輸出。

  public class a

  {

  public static void main(String[] args)

  {

  double x[]={25.3,56.3,15.3,125.25,465.36,456.32,458.21,456.325,4856.3215,41.6};


【9月計算機二級考試JAVA考試題及答案】相關文章:

2017年9月計算機二級Java機考試題及答案09-14

9月計算機等級考試二級Java試題10-29

2017年9月計算機二級MSOffice考試題「帶答案」09-08

2016年12月計算機二級考試Java練習及答案10-08

2017年3月計算機二級考試《VB》考試題及答案08-22

2016年9月計算機二級《C++》機考試題及答案08-11

2017年9月計算機二級C++備考試題及答案10-29

2017年9月計算機二級MSOffice備考試題「帶答案」10-02

2016年3月計算機二級MSOffice考試題及答案08-10

2024年12月計算機二級office考試題及答案10-24

主站蜘蛛池模板: 田林县| 榆树市| 共和县| 剑川县| 西充县| 游戏| 南平市| 乌拉特前旗| 蒲城县| 保德县| 金溪县| 恩平市| 台江县| 龙井市| 揭西县| 兴城市| 乐平市| 股票| 昆明市| 福贡县| 共和县| 田东县| 东阳市| 崇仁县| 财经| 四会市| 林州市| 南平市| 新营市| 弥渡县| 开化县| 北宁市| 凌海市| 聂拉木县| 塔城市| 满城县| 巴楚县| 台江县| 朝阳县| 陆良县| 乌海市|