
正文
java人民币换美元代码 人民币转换美元的编程
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
用java写一个汇率的程序:将人民币与美元、欧元、英镑等多种货币的汇率保存在指定文件中,设计图形用
程序java人民币换美元代码:
import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class test8{ public static void main(String[] args) { JFrame f=new JFrame(); f.setSize(200java人民币换美元代码, 200); JTextArea t1 = new JTextArea(1,5); JTextArea t2 = new JTextArea(1,5); JButton b1=new JButton("test it"); Label l1,l2; l1 = new Label(); l2 = new Label(); l1.setText("Please Enter The Number"); l2.setText("The Result Of The Test"); Choice c = new Choice(); c.add("RMB"); c.add("KRW"); c.add("DOLLAR"); Choice c1 = new Choice(); c1.add("RMB"); c1.add("KRW"); c1.add("DOLLAR"); f.add(l1); f.add(t1); f.add(c); f.add(l2); f.add(t2); f.add(c1); f.add(b1); b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {if(c.getSelectedItem()=="RMB"c1.getSelectedItem()=="DOLLAR") {String s; s=t1.getText(); int q=0; q=Integer.parseInt(s); double w; w=q*0.1452; String r = Double.toString(w); t2.setText(r); } else if(c.getSelectedItem()=="DOLLAR"c1.getSelectedItem()=="RMB") {String s; s=t1.getText(); int q=0; q=Integer.parseInt(s); double w; w=q*6.8866; String r = Double.toString(w); t2.setText(r); } else if(c.getSelectedItem()=="RMB"c1.getSelectedItem()=="KRW") {String s; s=t1.getText(); int q=0; q=Integer.parseInt(s); double w; w=q*164.9824; String r = Double.toString(w); t2.setText(r); } else if(c.getSelectedItem()=="KRW"c1.getSelectedItem()=="RMB") {String s; s=t1.getText(); int q=0; q=Integer.parseInt(s); double w; w=q*0.0061; String r = Double.toString(w); t2.setText(r); } else if(c.getSelectedItem()=="DOLLAR"c1.getSelectedItem()=="KRW") {String s; s=t1.getText(); int q=0; q=Integer.parseInt(s); double w; w=q*1136.2500; String r = Double.toString(w); t2.setText(r); } else if(c.getSelectedItem()=="KRW"c1.getSelectedItem()=="DOLLAR") {String s; s=t1.getText(); int q=0; q=Integer.parseInt(s); double w; w=q*0.0009; String r = Double.toString(w); t2.setText(r); } } } ); f.setLayout(new FlowLayout()); f.setVisible(true); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } }
操作环境:java 版型号:8.64
拓展资料:
1、Java是一门面向对象编程语言,不仅吸收java人民币换美元代码了C++语言java人民币换美元代码的各种优点,还摒弃了C++里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征。Java语言作为静态面向对象编程语言的代表,极好地实现了面向对象理论,允许程序员以优雅的思维方式进行复杂的编程。 Java具有简单性、面向对象、分布式、健壮性、安全性、平台独立与可移植性、多线程、动态性等特点。Java可以编写桌面应用程序、Web应用程序、分布式系统和嵌入式系统应用程序等
2、由于C++所具有的优势,该项目组的研究人员首先考虑采用C++来编写程序。但对于硬件资源极其匮乏的单片式系统来说,C++程序过于复杂和庞大。另外由于消费电子产品所采用的嵌入式处理器芯片的种类繁杂,如何让编写的程序跨平台运行也是个难题。为了解决困难,他们首先着眼于语言的开发,假设了一种结构简单、符合嵌入式应用需要的硬件平台体系结构并为其制定了相应的规范,其中就定义了这种硬件平台的二进制机器码指令系统(即后来成为“字节码”的指令系统),以待语言开发成功后,能有半导体芯片生产商开发和生产这种硬件平台。对于新语言的设计,Sun公司研发人员并没有开发一种全新的语言,而是根据嵌入式软件的要求,对C++进行了改造,去除了留在C++的一些不太实用及影响安全的成分,并结合嵌入式系统的实时性要求,开发了一种称为Oak的面向对象语言。
操作环境:java 版型号:8.64
操作环境:C++ 版型号:8.2.64
相关问答
Q1: java程序。 输入为CNY USD等货币缩写。 输出为 ¥ $等 该货币的符号。currency类
因为我们用的都是中文环境(默认),所以你的程序只能输入中国的货币符号,要通过Locale类的java人民币换美元代码: public static void setDefault(Locale newLocale)方法设置下语言环境
具体代码可参考如下的java人民币换美元代码:
import java.util.Currency;
import java.util.Locale;
import java.util.Scanner;
/**
*
* @author top
*/
public class CurrencySymbol {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Please input a valid ISO 4217 currency code: ");
Scanner scan = new Scanner(System.in);
String code1 = scan.nextLine();
Locale.setDefault(Locale.CHINA);//中文语言环境下
Currency currency1 = Currency.getInstance(code1);
System.out.println(currency1.getSymbol());
String code2 = scan.nextLine();
Locale.setDefault(Locale.US);//美国
Currency currency2 = Currency.getInstance(code2);
System.out.println(currency2.getSymbol());
}
}
Q2: java 美元人民币汇率转换小问题,跳出的这个框的标题“输入”是在哪里设置的?怎么更改?
//JDK API 1.6.0
showInputDialog(Component parentComponent, Object message, String title,
int messageType)
显示请求用户输入内容的对话框,它以
parentComponent 为父级,该对话框的标题为 title,消息类型为
messageType。
实例:
JOptionPane.showInputDialog(null, "gain focus!","tiltle",JOptionPane.NO_OPTION);
Q3: 在java中人民币汇率转换成美元和欧元怎么写打码
public class Test {public static void main(String args[]){String word = "hello world ! 123456 hI, tHEre";String[] words =word.split(" "); for (int i = 0; i words.length; i++) {for (int j = 0; j words[i].length(); j++) {if (j==0) {System.out.print((words[i].charAt(j)+"").toUpperCase());} else {System.out.print((words[i].charAt(j)+"").toLowerCase());}}System.out.print(" ");}}}使用空格区分单词,自动单词首字母大写,其他部分小写。如果单词首字母以外的部分不需要修改的话把else删掉即可。
Q4: 用java编写一个程序,可实现人民币,美元,日元,欧元,台币,港币之间的任意转换
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(total0){
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+"张");
}
}
}
java人民币换美元代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于人民币转换美元的编程、java人民币换美元代码的信息别忘了在本站进行查找喔。







