Java 被告知地点;用我的方法
问题似乎就在这里:Java 被告知地点;用我的方法,java,Java,问题似乎就在这里: import java.util.Scanner; public class CoinCounter { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.print("Enter the number of toonies: "); int t = keyboard.nextInt();
import java.util.Scanner;
public class CoinCounter {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the number of toonies: ");
int t = keyboard.nextInt();
System.out.print("Enter the number of loonies: ");
int l = keyboard.nextInt();
System.out.print("Enter the number of quarters: ");
int q = keyboard.nextInt();
System.out.print("Enter the number of dimes: ");
int d = keyboard.nextInt();
System.out.print("Enter the number of nickels: ");
int n = keyboard.nextInt();
int coinCounter = total(t,l,q,d,n);
System.out.println("The total value of the coins is " + coinCounter + " cents");
finalMessage;
static int total(int t , int l , int q , int d , int n) {
return t*200 + l*100 + q*25 + d*10 + n*5;
}//total of coins
static String finalMessage( ); {
System.out.print("Cole Coin Counter Company, 2014");
}//final message
}//main
}//coinCounter
那应该是
finalMessage;
另外,在方法中嵌套了一个方法-坏消息。最终消息不应在主消息内
这将产生语法错误,因为:;在你离开后。简单地省略它,就像这样:
static String finalMessage( ); {
static String finalMessage() {
正如Steve指出的,当调用方法时,必须使用括号,如下所示:
static String finalMessage( ); {
static String finalMessage() {
此外,Steve还指出,方法的定义必须在所有其他方法之外 错误信息是什么?具体是什么?您不明白吗?我可以看到你代码中的错误,但实际上,你应该尝试解释错误消息,否则你不会走得太远。嗨,科尔,欢迎这么说。错误来自最后一条消息,说variabledclarators。公共静态int totalint t,int l,int q,int d,int n中似乎也有错误,说我不应该有括号和;这里没有逗号,发生了什么?main的右大括号似乎放得太晚了。我相信结束括号应该在static int total之前…^这家伙是个救命恩人^我知道我做的一切都是正确的,因为从编码的角度来看,它必须是一个愚蠢的小括号。非常感谢你的帮助。你不知道我和它斗争了多久,也许我也想看看下面的六行……直到你指出它们,我才注意到它们。所以,基本语法错误…@NathanielFord-是的,但我认为你已经回答了实际问题,或者至少回答了标题所指的内容;