[英]How to solve syntax error in eclipse Mars.1
Here is my code :这是我的代码:
import java.util.Scanner
class VersatileSnitSoft
public static void main (String [] args) {
double amount;
System.out.print (*What is the price of CD-ROM? *)
amount = myScanner.nextDouble ();
amount = amount + 25.00;
System.out.print(*We will bill R*);
System.out.print(amount);
System.out.printIn(* to your credit card.*)
}
}
System.out.print(*What is the price of CD-ROM? *)
字符串应包含在""
而不是**
并且此语句末尾的分号在哪里。
Your code should be right in this mode.在这种模式下,您的代码应该是正确的。
import java.util.Scanner;
public class VersatileSnitSoft {
public static void main (String [] args) {
double amount;
Scanner myScanner = new Scanner(System.in);
System.out.print ("What is the price of CD-ROM? ");
amount = myScanner.nextDouble ();
amount = amount + 25.00;
System.out.print("We will bill R ");
System.out.print(amount);
System.out.println(" to your credit card.");
}
}
try to read some tuturial like this Learn java尝试阅读一些像这样的教程Learn java
There weren't many things correct here.这里没有很多事情是正确的。 I suggest you start from the bottom and actually read up on how the syntax looks, how the language works.
我建议你从底层开始,仔细阅读语法的外观,语言的工作原理。
That being said, your code now looks话虽如此,您的代码现在看起来
import java.util.Scanner;
class VersatileSnitSoft {
public static void main (String [] args) {
double amount;
Scanner myScanner = new Scanner (System.in);
System.out.print ("What is the price of CD-ROM? ");
amount = myScanner.nextDouble ();
amount += 25.00;
System.out.print("We will bill R" + amount + " to your credit card.");
myScanner.close();
}
}
The changes made are:所做的更改是:
printIn
which doesn't exist, I suggest it was supposed to be println (...)
printIn
了自己不存在的方法printIn
,我建议它应该是println (...)
*
around a string instead of quotation "
.*
而不是引号"
。;
;
at the end of one line.Scanner
, which I showed how now.Scanner
,我现在展示了它。 For the future, read the error messages and try to understand them, at least share them with us.对于未来,阅读错误消息并尝试理解它们,至少与我们分享它们。 This code now produces zero errors.
此代码现在产生零错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.