这是我的代码:
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.*)
}
}
答案 0 :(得分:2)
System.out.print(*What is the price of CD-ROM? *)
字符串应该包含在""
而不是**
中,并且在此语句末尾的半冒号位置。
答案 1 :(得分:2)
您的代码应该在此模式下正确。
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.");
}
}
尝试阅读像Learn java
这样的tuturial答案 2 :(得分:0)
这里没有太多正确的事情。我建议你从底部开始,实际阅读语法的外观,语言的工作原理。
话虽如此,您的代码现在看起来
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();
}
}
所做的更改是:
printIn
,这个方法不存在,我建议它应该是println (...)
*
而不是引用"
。;
。Scanner
。将来,请阅读错误消息并尝试理解它们,至少与我们分享。此代码现在产生零错误。