- 相關(guān)推薦
計(jì)算機(jī)語(yǔ)言Java考試模擬試題附答案
科學(xué)的未來(lái)只能是屬于勤奮而又謙虛的年輕一代!以下是小編為大家搜索整理的計(jì)算機(jī)語(yǔ)言Java考試模擬試題附答案,希望能給大家?guī)?lái)幫助!更多精彩內(nèi)容請(qǐng)及時(shí)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!
1、編寫(xiě)程序,計(jì)算下列分段函數(shù)的值。
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("請(qǐng)輸入x:");
String temp=input.readLine();
x = Float.parseFloat(temp);
if(x>=0)
{
y=x;
}else
{
y=-x;
}
System.out.println("y="+y);
}
}
2、根據(jù)年齡,判斷某人是否為成年。
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("請(qǐng)輸入x:");
String temp=input.readLine();
x = Float.parseFloat(temp);
if(x>=18)
{
System.out.println("成年人");
}
if(x<18)
{
System.out.println("未成年");
}
}
}
3、判斷2020的奇偶性,并進(jìn)行輸出。
public class test
{
public static void main(String[] args)
{
int x;
x=2020;
if(x%2==0)
System.out.println(+x+"是偶數(shù)");
else
System.out.println(+x+"不是偶數(shù)");
}
}
4、比較兩個(gè)數(shù)的大小,找出其中的最大數(shù)并輸出。
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("請(qǐng)輸入x:");
String tempx=inputx.readLine();
x = Float.parseFloat(tempx);
InputStreamReader readery=new InputStreamReader(System.in);
BufferedReader inputy=new BufferedReader(readery);
System.out.println("請(qǐng)輸入y:");
String tempy=inputy.readLine();
y= Float.parseFloat(tempy);
if(x>y)
{
m=x;
}else
{
m=y;
}
System.out.println("最大數(shù)為"+m);
}
}
5、比較兩個(gè)數(shù)的大小,找出其中的最小數(shù)并輸出。
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("請(qǐng)輸入x:");
String tempx=inputx.readLine();
x = Float.parseFloat(tempx);
InputStreamReader readery=new InputStreamReader(System.in);
BufferedReader inputy=new BufferedReader(readery);
System.out.println("請(qǐng)輸入y:");
String tempy=inputy.readLine();
y= Float.parseFloat(tempy);
if(x{
m=x;
}else
{
m=y;
}
System.out.println("最小數(shù)為"+m);
}
}
6、編寫(xiě)一個(gè)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("請(qǐng)輸入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、比較兩個(gè)數(shù)的大小,找出其中的最大數(shù)和最小數(shù)并輸出。
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("請(qǐng)輸入x:");
String tempx=inputx.readLine();
x = Float.parseFloat(tempx);
InputStreamReader readery=new InputStreamReader(System.in);
BufferedReader inputy=new BufferedReader(readery);
System.out.println("請(qǐng)輸入y:");
String tempy=inputy.readLine();
y= Float.parseFloat(tempy);
if(x{
System.out.println("最小數(shù)為"+x);
System.out.println("最大數(shù)為"+y);
}else
{
System.out.println("最小數(shù)為"+y);
System.out.println("最大數(shù)為"+x);
}
}
}
8、比較兩個(gè)數(shù)的大小,找出其中的最大數(shù)和最小數(shù),并輸出最大數(shù)和最小數(shù)之差。
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("請(qǐng)輸入x:");
String tempx=inputx.readLine();
x = Float.parseFloat(tempx);
InputStreamReader readery=new InputStreamReader(System.in);
BufferedReader inputy=new BufferedReader(readery);
System.out.println("請(qǐng)輸入y:");
String tempy=inputy.readLine();
y= Float.parseFloat(tempy);
if(x{
System.out.println("最小數(shù)為"+x);
System.out.println("最大數(shù)為"+y);
【計(jì)算機(jī)語(yǔ)言Java考試模擬試題附答案】相關(guān)文章:
2017年Java計(jì)算機(jī)考試模擬試題附答案09-05
java考試模擬試題06-29
計(jì)算機(jī)考試二級(jí)考試Java模擬試題附答案11-14
java考試模擬練習(xí)試題08-30
全國(guó)計(jì)算機(jī)考試二級(jí)考試Java模擬試題附答案08-17
稅務(wù)師考試模擬試題目(附答案)08-20
2017年托福閱讀考試模擬試題附答案07-08
計(jì)算機(jī)考試Java模擬試題及答案201706-18
2017年java考試模擬試題07-15