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

熱點內容
文件不能復制到手機 瀏覽:135
javaweb學生選課系統 瀏覽:111
app怎麼切vr 瀏覽:47
安卓so文件反編譯工具 瀏覽:169
微信支付服務商版區別 瀏覽:361
網路測試一切正常為什麼上不去網 瀏覽:315
nodejsweb伺服器 瀏覽:566
如何攻擊一個博客網站 瀏覽:998
視頻文件格式有cd格式嗎 瀏覽:878
聯想壁紙文件夾 瀏覽:164
qq刪人怎麼還隱蔽 瀏覽:344
秒變肌肉男app 瀏覽:348
右鍵刪除後文件找不到 瀏覽:741
小米平板2代碼 瀏覽:46
揭陽看房上哪個網站 瀏覽:491
正版win10用u盤安裝失敗怎麼辦 瀏覽:268
寶馬app怎麼放在手機桌面 瀏覽:630
ch341linux 瀏覽:901
牧馬人升級版shift模式 瀏覽:182
文件夾共享了訪問不了 瀏覽:729

友情鏈接