华南俳烁实业有限公司

考試首頁 | 考試用書 | 培訓(xùn)課程 | 模擬考場 | 考試論壇  
全國  |             |          |          |          |          |         
  當(dāng)前位置:計算機等級 > 二級考試 > Java語言程序設(shè)計 > 模擬試題 > 文章內(nèi)容
  

全國計算機等級考試二級Java模擬試題及答案(29)

中華IT學(xué)院   【 】  [ 2016年11月22日 ]

m=y-x;
System.out.println("最大數(shù)與最小數(shù)之差為"+m);
}else
{
System.out.println("最小數(shù)為"+y);
System.out.println("最大數(shù)為"+x);
m=x-y;
System.out.println("最大數(shù)與最小數(shù)之差為"+m);
}
}
}
9、編寫程序,計算下列分段函數(shù)的值。
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、編寫程序,計算下列分段函數(shù)的值。
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 2 尾頁
分享到:
本文糾錯】【告訴好友】【打印此文】【返回頂部
將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動訪問考試網(wǎng) | 復(fù)制本頁地址,傳給QQ/MSN上的好友 | 申請鏈接 | 意見留言 TOP
關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved
微博| 竹山县| 望都县| 赣榆县| 梅河口市| 新乡市| 西丰县| 外汇| 昭觉县| 尤溪县| 黔南| 邯郸市| 龙泉市| 大埔区| 商都县| 宝丰县| 仁怀市| 潞城市| 泰安市| 旺苍县| 克拉玛依市| 马山县| 麟游县| 张掖市| 息烽县| 甘泉县| 云南省| 云龙县| 武胜县| 郁南县| 沈丘县| 双峰县| 琼中| 梓潼县| 丹阳市| 靖远县| 竹溪县| 紫云| 龙胜| 大洼县| 旌德县|