java币种换算代码 java金额转换

JAVA问题:一个程序能换算美金单位

public static void main(String[] args) {

创新互联建站专注于南昌县企业网站建设,响应式网站建设,商城网站开发。南昌县网站建设公司,为南昌县等地区提供建站服务。全流程按需求定制开发,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务

Scanner sca = new Scanner(System.in);

System.out.println("输入美元数");

int dollars = sca.nextInt();

System.out.println("输入美分数");

int cents = sca.nextInt();

int all = dollars * 100 + cents;

System.out.println(all / 100 + "dollars" + all % 100 / 25 + "quarter"

+ all % 25 / 10 + "dimes" + all % 10 / 5 + "nickets" + all % 5

+ "cents");

}

用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(200, 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是一门面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征。Java语言作为静态面向对象编程语言的代表,极好地实现了面向对象理论,允许程序员以优雅的思维方式进行复杂的编程。 Java具有简单性、面向对象、分布式、健壮性、安全性、平台独立与可移植性、多线程、动态性等特点。Java可以编写桌面应用程序、Web应用程序、分布式系统和嵌入式系统应用程序等

2、由于C++所具有的优势,该项目组的研究人员首先考虑采用C++来编写程序。但对于硬件资源极其匮乏的单片式系统来说,C++程序过于复杂和庞大。另外由于消费电子产品所采用的嵌入式处理器芯片的种类繁杂,如何让编写的程序跨平台运行也是个难题。为了解决困难,他们首先着眼于语言的开发,假设了一种结构简单、符合嵌入式应用需要的硬件平台体系结构并为其制定了相应的规范,其中就定义了这种硬件平台的二进制机器码指令系统(即后来成为“字节码”的指令系统),以待语言开发成功后,能有半导体芯片生产商开发和生产这种硬件平台。对于新语言的设计,Sun公司研发人员并没有开发一种全新的语言,而是根据嵌入式软件的要求,对C++进行了改造,去除了留在C++的一些不太实用及影响安全的成分,并结合嵌入式系统的实时性要求,开发了一种称为Oak的面向对象语言。

操作环境:java 版型号:8.64

操作环境:C++ 版型号:8.2.64

java程序。 输入为CNY USD等货币缩写。 输出为 ¥ $等 该货币的符号。currency类

因为我们用的都是中文环境(默认),所以你的程序只能输入中国的货币符号,要通过Locale类的: public static void setDefault(Locale newLocale)方法设置下语言环境

具体代码可参考如下的:

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());

}

}

请问怎么写一个关于货币兑换的java代码?请完整的写完告诉我,谢谢~~

输入一个美圆数字?然后输出等值的人民币?

假设一美圆兑换7.5人民币~

public class A

{

public static void main(String[] args)

{

System.out.println("请输入,只能是数字!");

String serial = inputString();

System.out.println(Long.parseLong(serial)*7.5)

}

private static String inputString()

{

BufferedReader bufferedreader = new BufferedReader(

new InputStreamReader(System.in));

String s = null;

try

{

s = bufferedreader.readLine();

}

catch (IOException ioexception)

{

ioexception.printStackTrace();

}

return s;

}

}


新闻名称:java币种换算代码 java金额转换
网站URL:http://lszwz.com/article/dosdhgs.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款