成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

java分轉(zhuǎn)元代碼 java amp轉(zhuǎn)換

用java編寫一個(gè)程序,可實(shí)現(xiàn)人民幣,美元,日元,歐元,臺(tái)幣,港幣之間的任意轉(zhuǎn)換

package?Test;

成都創(chuàng)新互聯(lián)公司是一家專注于成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、外貿(mào)營銷網(wǎng)站建設(shè)與策劃設(shè)計(jì),高碑店網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:高碑店等地區(qū)。高碑店做網(wǎng)站價(jià)格咨詢:18982081108

import?javax.swing.JOptionPane;

public?class?Test2?{

public?static?void?main(String[]?args)?{

int?numOf10=0;

int?numOf5=0;

int?numOf1=0;

坦裂?int?numOf0_5=0;

int?numOf0_1=0;

Double?money=Double.parseDouble(JOptionPane.showInputDialog("輸入money"));

int?total=(int)(money*10);

while(total0){

if((total-100)=0){

悔數(shù)??total-=100;

numOf10++;

}else?if((total-50)=0){

total-=50;

numOf5++;

}else?if((total-10)=0){??

total-=10;??

numOf1++;

}else?if((total-5)=0){?

total-=5;??

numOf0_5++;

}else?if((total-1)=0){

total-=1;????

numOf0_1++;

}

}

if(numOf10!=0){

System.out.println("10元人民幣:"+numOf10+"張");

}

if(numOf5!=0){

System.out.println("5元人民幣:"+numOf5+"張");

}

if(numOf1!=0){

System.out.println("1元人民幣:"+numOf1+"張");

}

if(numOf0_5!=0){

System.out.println("5角人民幣:"+numOf0_5+"張");

}

if(numOf0_1!=0){

System.out.println("1角人民幣讓前閉:"+numOf0_1+"張");

}

}

}

在java中怎樣把元轉(zhuǎn)成分.0

java中不可以通過強(qiáng)制轉(zhuǎn)換將true和false轉(zhuǎn)知態(tài)換成1和0 因?yàn)椴紶栴愋团c其他基本類型數(shù)據(jù)不可族巧以搭穗源互相轉(zhuǎn)換 可以用條件運(yùn)算符 int a=(b==true)?1:0;//如果b為true則給a賦值1,如果為false則賦值0

注釋java人民幣小寫轉(zhuǎn)換大寫的代碼

publicstatic String toRMB(double money) {

char[] s1 = {'零', '壹', '貳', '叁', '肆', '伍', '陸', '柒', '捌', '玖'};

char[] s4 = {'分', '角', '元', '拾', '佰', '仟', '萬', '拾', '佰', '仟', '億', '拾', '佰', '仟', '萬'};

//這兩句是為后面轉(zhuǎn)換做字典準(zhǔn)備

String str = String.valueOf(Math.round(money * 100 + 0.00001));

//這是把參數(shù)money小數(shù)點(diǎn)后移2位,然后取整,即按照“分”為單位取整,再轉(zhuǎn)為字符串型

String result = "";

for (int i = 0; i str.length(); i++) {

int n = str.charAt(str.length() - 1 - i) - '0';

result = s1[n] + "" + s4[i] + result;

}

//這一段是按照轉(zhuǎn)換出來的字符串按位取數(shù)字,再按照上面的字典將其逐位翻譯成漢字

//如“2011”就翻譯成“貳仟零佰壹拾壹元”,“98700432.10”就是“玖仟捌佰柒拾零萬零仟肆佰叁拾貳元壹角零分”——注:這里的人民幣大寫漢字,貌似有錯(cuò)誤,請查閱相關(guān)資料更正

//以上的翻納和譯可以洞信盯看出,和我們平時(shí)的認(rèn)讀有差別,于是以下就是在將那些應(yīng)該糾正的地方手動(dòng)剔除以下。上述兩個(gè)例子最后得到的結(jié)果應(yīng)該是“貳仟零壹拾壹元整”,“玖仟捌佰柒拾萬零肆佰叁拾貳元壹角整”

result = result.replaceAll("零仟", "零");

result = result.replaceAll("零佰", "零");

result = result.replaceAll("零拾", "零");

result = result.replaceAll("零億", "億");

result = result.replaceAll("零萬", "萬");

result = result.replaceAll("零元", "元");

result = result.replaceAll("零角", "零");

result = result.replaceAll("零分", "零");

result = result.replaceAll("零零", "零");

result = result.replaceAll("零億", "億");

result = result.replaceAll("零零", "零");

result = result.replaceAll("零萬", "萬");

result = result.replaceAll("零零", "零");

result = result.replaceAll("零元", "元");

result = result.replaceAll("坦鎮(zhèn)億萬","億");

result = result.replaceAll("零$", "");

result = result.replaceAll("元$", "元整");

result = result.replaceAll("角$", "角整");

return result;

}

JAVA程序 輸入一串?dāng)?shù)字如12341289.23,輸出萬千百十元角分。高手幫忙!謝謝

//將人民幣金額冊兆晌轉(zhuǎn)換為大寫

function upDigit(n){

var fraction = ["角","分"];

var digit = ["零","壹","貳","叁","肆","伍"州鋒,"陸","柒","捌","玖"];

var unit = [["元","萬","億"],[""猜逗,"拾","佰","仟"]];

var head = n0?"負(fù)":"";

n = Math.abs(n);

var s = "";

for(var i=0; ifraction.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; iunit[0].length n0; i++){

var p = "";

for(var j=0; junit[1].length n0; 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(/(^整$)/,"零元整");

}

文章標(biāo)題:java分轉(zhuǎn)元代碼 java amp轉(zhuǎn)換
新聞來源:http://jinyejixie.com/article30/ddpegso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、面包屑導(dǎo)航、搜索引擎優(yōu)化品牌網(wǎng)站制作、網(wǎng)站營銷微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司
海安县| 会宁县| 中方县| 麦盖提县| 札达县| 鹤岗市| 图片| 长宁县| 禄丰县| 长兴县| 运城市| 东兰县| 长泰县| 柞水县| 临沭县| 车致| 理塘县| 昌图县| 腾冲县| 宝应县| 德庆县| 哈尔滨市| 九寨沟县| 修武县| 渭源县| 河津市| 尤溪县| 镇平县| 绩溪县| 光泽县| 株洲县| 苍梧县| 铜川市| 页游| 渭南市| 高清| 田阳县| 沅江市| 左权县| 呼和浩特市| 寻乌县|