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

熱點內容
如何知道別人使用我的電腦和看了什麼文件 瀏覽:712
prcs4視頻導出後找不到文件 瀏覽:977
msp430系列單片機實用c語言程序設計 瀏覽:423
移動硬碟的文件格式 瀏覽:904
文件本地路徑與雲路徑 瀏覽:103
進大白菜找不到系統文件 瀏覽:380
ug裝配體找不到文件部件已刪除 瀏覽:629
小網站怎麼弄出來 瀏覽:649
jsp表單加參數 瀏覽:607
蘋果5s手機老是卡屏 瀏覽:58
js給php變數賦值 瀏覽:446
雜志版本號是什麼意思 瀏覽:223
地圖特效代碼 瀏覽:192
去除思科配置文件中的號 瀏覽:196
運行的16位程序太多 瀏覽:1
蘋果mac用什麼軟體好學編程 瀏覽:681
ai中線段怎麼添加寬度配置文件 瀏覽:956
lol文件怎麼找不到game 瀏覽:142
aecc視頻教程 瀏覽:983
linux怎麼查看資料庫用戶名 瀏覽:182

友情鏈接