導航:首頁 > 編程語言 > 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中的計費項目相關的資料

熱點內容
我的世界什麼版本好玩 瀏覽:341
控制專碩如何報考編程 瀏覽:534
元祖在編程里是什麼意思 瀏覽:491
小碼王為什麼比核桃編程貴 瀏覽:627
qq下載app有哪些 瀏覽:380
旅遊app的社區模塊有什麼 瀏覽:847
盜版win7怎樣升級win10 瀏覽:524
怎麼壓縮文件夾不超過10mb 瀏覽:770
網路攝像頭如何外網訪問 瀏覽:178
刷入的cp文件是什麼 瀏覽:513
dcp文件是什麼 瀏覽:427
win10驅動刪不了怎麼辦啊 瀏覽:459
win7如何做共享文件夾圖標 瀏覽:178
魔獸120怎麼升級124 瀏覽:395
智能健康手錶下載什麼app 瀏覽:664
想在協和醫院掛號怎麼下載app 瀏覽:86
關於科技產品需要哪些數據 瀏覽:623
linux命令行修改文件內容 瀏覽:526
java通信框架有哪些 瀏覽:331
哪裡看美國報紙app 瀏覽:753

友情鏈接