導航:首頁 > 編程語言 > java分轉換為元

java分轉換為元

發布時間:2023-03-22 22:01:55

『壹』 一演算法題java實現,有一分錢,兩分錢,五分錢,加起來等於10元錢。有多少種方法,並列印出來高手指教

一共50401組數據

public class ABC {
public static void main(String args[]) {

final int total = 1000;/穗渣/一共1000分

int count = 0;
for(int one = 0; one <= total / 1; one++){//察好1分錢數目
for(int two = 0; two <= total / 2; two++){//2分錢數目
for(int five = 0; five <= total / 5; five++){//5分錢數目
if(one*1 + two*2 + five *5 == total){
System.out.println("1*" + one + "敗族鉛 + 2*" + two + " + 5*" + five + "= 1000" );
count++;
}
}
}
}

System.out.println("Total possible " + count + " group!");
}
}
------------------
。。。。。
1*996 + 2*2 + 5*0= 1000
1*998 + 2*1 + 5*0= 1000
1*1000 + 2*0 + 5*0= 1000
Total possible 50401 group!

『貳』 Java定義一個表示人民幣的類Money,

public class Money {
private int yuan;
private int jiao;
private int fen;

public Money(int yuan,int jiao, int fen){
this.yuan=yuan;
this.jiao=jiao;
this.fen=fen;

}

public void show(){

System.out.printf("%d元回%d角%d分",yuan,jiao,fen);

}

public static void main(String[] args) {
答Money m=new Money(4,5,6);
m.show();

}

}

『叄』 JAVA程序 輸入一串數字如12341289.23,輸出萬千百十元角分。高手幫忙!謝謝

//將人民幣金額轉換為大寫
function upDigit(n){
var fraction = ["角","分"];
var digit = ["零","壹","貳","叄","肆","伍","陸","柒","捌","玖"];
var unit = [["元","萬","億"],["","拾","佰","仟"]];
var head = n<0?"負":"";
n = Math.abs(n);

var s = "";
for(var i=0; i<fraction.length; i++){
s += (digit[Math.floor(n*10*Math.pow(10,i))%10]+fraction[i]).replace(/零./,"");
}

s = s||"整";
n = Math.floor(n);

for(var i=0; i<unit[0].length && n>0; i++){
var p = "";
for(var j=0; j<unit[1].length && n>0; j++){
p = digit[n%10] + unit[1][j]+p;
n = Math.floor(n/10);
}
s = p.replace(/(零.)*零$/,"").replace(/^$/,"零") + unit[0][i] + s;
}
return head + s.replace(/(零.)*零元/,"元").replace(/(零.)+/g,"零").replace(/(^整$)/,"零元整");
}

閱讀全文

與java分轉換為元相關的資料

熱點內容
網路中常用的傳輸介質 瀏覽:518
文件如何使用 瀏覽:322
同步推密碼找回 瀏覽:865
樂高怎麼才能用電腦編程序 瀏覽:65
本機qq文件為什麼找不到 瀏覽:264
安卓qq空間免升級 瀏覽:490
linux如何刪除模塊驅動程序 瀏覽:193
at89c51c程序 瀏覽:329
怎麼創建word大綱文件 瀏覽:622
裊裊朗誦文件生成器 瀏覽:626
1054件文件是多少gb 瀏覽:371
高州禁養區內能養豬多少頭的文件 瀏覽:927
win8ico文件 瀏覽:949
仁和數控怎麼編程 瀏覽:381
項目文件夾圖片 瀏覽:87
怎麼在東芝電視安裝app 瀏覽:954
plc顯示數字怎麼編程 瀏覽:439
如何辨別假網站 瀏覽:711
寬頻用別人的賬號密碼 瀏覽:556
新app如何佔有市場 瀏覽:42

友情鏈接