是比较新的Java编程和因为它涉及到挥杆方面错误运行导入javax.swing.JOptionPane中
import java.io.*;
import Java.text.DecimalFormat;
public class CurrencyConverter
{
public static void main(string[]args)throws IOException
{
String USDollar;
double USD, Euro, Pounds, Rouble;
BufferedReader dataIn=new BufferedReader (newInputStreamReader(System.in));
System.out.println();
System.out.println("\t\t CURRENCY CONVERTER");
System.out.println("\t\t Please enter the Dollar amount in US DOLLAR");
USDollar=dataIn.readLine();
USD=Double.parseDouble(USDollar);
Rouble=(USD*34.89);
Pounds=(USD*0.61);
Euro=(USD*0.73);
System.out.println();
System.out.println("\t\tYour given amount $"+USD);
System.out.println("\t\tPounds $"+ Pounds);
System.out.println("\t\tRussian Rouble $"+ Rouble);
System.out.println("\t\tEuro $"+Euro);
}
}
import javax.swing.JOptionPane;
public class CSwing
{
public static void main(String[]args)
{
String USDollar;
double USD,Pounds,Rouble,Euros;
System.out.println("t\tCURRENCY CONVERTER");
USD = JOptionPane.showInputDialog(null,"Please enter the Dollar amount in USD");
dUSD=Double.parseDouble(USD);
Rouble=(USD*34.89);
Pounds=(USD*0.61);
Euro=(USD*0.73);
JOptionPane.showMessageDialog(null, "Your Given Amount: $" +(dUSD)
+"\n\nYour Rouble Conversion is:$"+(Rouble)
+"\n\nYour Pound Conversion is:$"+(Pound)
+"\n\nYour Euro Conversion is:$"+(Euro));
System.exit(0);
}
}
工具输出错误我收到了我的代码的输出错误:class, interface, enum expected: import javax.swing.JOptionpane
: 我为了自己解决这个问题而使用了Google,但我被卡住了。我解决了所有其他的错误,如果现在这是唯一的错误,但为什么我会遇到困难。您对此的协助将得到真正的赞赏。
是你必须在一个单一的文件中显示所有的代码?如果是,那么你需要将它分成两个文件(CurrencyConverter.java和CSwing.java)。 – assylias
这是插入代码本身,我如何拆分文件 – user3299431
它全部在currencyconverter.java下,所以我必须保存控制台与秋千分开是你的指示 – user3299431