【发布时间】:2014-10-19 03:40:05
【问题描述】:
我在这门课上的深度太差了。它应该是一个基本的货币转换器。我强调了在示例和我自己的代码中遇到问题的地方。我需要关于收集输入和输出输入的建议,具体取决于我的输入(如果有意义的话)。我的代码在下面,它仍处于起步阶段。
程序的输出应该如下所示:
(Example) Welcome to the Currency Converter Program (Example)
Use the following codes to input your currency choices:
1 – US Dollars
2 – Euros
3 – British Pounds
4 – Japanese Yen
Please choose the input currency: 2
Now choose the output currency: 1
Now enter the input in *Euros*: €10.00 <--- *This is where I am stuck at right now. How
can I get the output to say Euro's, dollars, yen, etc. depending on what my input
currency is?*
€10.00 Euros at a conversion rate of 1.5 Euros to Dollars = $15.00 US Dollars.
Thank you for using the Currency Converter Program!
===========================================================
公共类货币 {
public currency()
{
char us_dollar_sym = 36;
char pound_sym = 163;
char yen_sym = 165;
char euro_sym = 8364;
double us_dollar = 0;
double pound = 0;
double yen = 0;
double euro =0;
// Interface
System.out.println("Welcome to the Currency Converter Program \n");
System.out.println("Use the following codes to input your currency choices: \n 1 - US dollars \n 2 - Euros \n 3 - British Pounds \n 4 - Japanese Yen \n");
// Collect user input
System.out.println("Please choose the input currency:");
Scanner in = new Scanner(System.in);
String choice = in.next();
System.out.println("Please choose the output currency");
String output = in.next();
System.out.printf("Now enter the input in"); <-- Stuck here
double input = in.nextInt();
}
}
【问题讨论】:
标签: java input output currency