導航:首頁 > 編程語言 > java中的計費項目

java中的計費項目

發布時間:2024-10-27 14:28:20

『壹』 用java編寫一個電話計費卡程序

importjava.util.Scanner;


publicclassPhoneCard{
privatefinalintid;//卡號
privatefinalintpassword;//密碼
privatedoublecash;//剩餘金額
privatedoublecashPerMin=0.2;//每分鍾收費
privateScannersc=newScanner(System.in);

publicPhoneCard(intid,intpassword,doublecash){
this.id=id;
this.password=password;
this.cash=cash;
}

/**
*撥號計費
*@paramtime撥號時間單位分鍾
*返回剩餘金額
*/
publicdoublecallSomeone(doubletime){
System.out.println("請輸入卡號和密碼,用空格隔開");
intid=sc.nextInt();
intpw=sc.nextInt();
if(this.id==id&&this.password==pw){
this.cash=this.cash-(double)time*cashPerMin;
returncash;
}else{
System.out.println("密碼錯誤");
return-1;
}
}
}

publicclassTestPhoneCard{
publicstaticvoidmain(String[]args){
PhoneCardpc=newPhoneCard(1,1,100);//初始化,卡號,密碼,余額
doublemoney=pc.callSomeone(10);//撥打10分鍾
System.out.println("余額為"+money+"元");
money=pc.callSomeone(90);//繼續撥打
System.out.println("余額為"+money+"元");
}
}

不知道為什麼沒人做

『貳』 請教高手JAVA做電信的計費系統

首先要確定所用的技術 框架

先寫 實體類 在創建 資料庫里的表格,然後建立 hibernate映射文件,寫DAO

再寫Action Struts配置文件

最後寫JSP文件

『叄』 java編程問題: 某城市用水實行階梯計費,規則如下:對於生活用水:如

publicclassWaterRate{
inttype;
intquantity;
publicWaterRate(inttype,intquantity){
super();
this.type=type;
this.quantity=quantity;
}
publicdoublecalc(){
doublecash=0;
if(type==1){
if(quantity>10){
cash=10*2.5+(quantity-10)*3;
}else{
cash=quantity*2.5;
}
System.out.print("生活用水"+quantity+"噸,總計:");
}elseif(type==2){
if(quantity>20){
cash=10*3.9+(quantity-10)*4.8;
}else{
cash=quantity*3.9;
}
System.out.print("商業用水"+quantity+"噸,總計:");
}else{
System.out.println("請輸入正確的類型(1生活用水2商業永碩)");
}
System.out.println(cash+"元");
returncash;
}
publicstaticvoidmain(String[]args){
newWaterRate(1,16).calc();
newWaterRate(2,35).calc();
}
}
之前就回答你了╮(╯_╰)╭

『肆』 一個簡單的Java程序代碼

public double GetCost(int minutes)
{
//整數時間所花的費用
int aa = minutes / 60; //未滿1小時處理
if (minutes < 60)
return 2;

//超出小時部分
int bb = minutes % 60; //其實你還有必要做一些其他處理。比如說超過30分鍾了該怎麼樣算等等...... return aa * 2 + bb * 0.01d;
}

閱讀全文

與java中的計費項目相關的資料

熱點內容
姑蘇區五軸聯動數控編程如何學 瀏覽:499
初學電腦編程軟體哪個好用 瀏覽:133
dnf86版本魔道和元素 瀏覽:730
黨的重要文件包括哪些 瀏覽:53
u盤ini文件不能復制 瀏覽:876
加工中心如何平面螺旋銑編程 瀏覽:323
計算機什麼配置適合設計和編程 瀏覽:252
如何注銷閑蛋app 瀏覽:194
js如何用trim 瀏覽:339
壁紙版本黛安娜 瀏覽:814
華為榮耀4a微信運動 瀏覽:307
allbackup文件夾找不到 瀏覽:333
哪個網站東西是正品 瀏覽:35
軟體安裝文件里圖片替換 瀏覽:697
微信小程序選擇器代碼 瀏覽:247
信息學和數據學哪個好 瀏覽:847
意外替換了ps文件 瀏覽:551
數控加工編程軟體漢語怎麼讀 瀏覽:685
直播間脫內衣的APP叫什麼 瀏覽:623
西門子plc編程軟體如何連接plc 瀏覽:354

友情鏈接