用java编写一个程序,可实现人民币,美元,日元,欧元,台币,港币之间的任意转换
1个回答
展开全部
package Test;
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(total>0){
if((total-100)>=0){
悔数 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+"张");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询