英文:
Java error: cannot find symbol when compiling
问题
/* =================================================
* 姓名:Kaleb Prichard
* 学号:140289
* 班级:CS 202 - 1
* 程序:4
* ================================================= */
import java.util.Scanner;
public class fourthProgram
{
// 程序从这里开始执行
public static void main(String[] args)
{
double mealCost, tax, mealCount, subtotal, total;
Scanner keyboard = new Scanner(System.in);
System.out.println("该程序将显示小票,显示购买金额、税费和总费用。");
System.out.println("一顿饭的费用是多少?");
mealCost = keyboard.nextDouble();
System.out.println("顾客购买了多少顿饭?");
mealCount = keyboard.nextDouble();
subtotal = mealCost * mealCount;
tax = 7.5 * subtotal;
total = subtotal + tax;
System.out.print(total % 5.2);
// TOTAL 以美元计算
}
}
每次我尝试编译这段代码时,都会收到一个错误消息:
> fourthProgram.java:13: 错误: 缺少方法体,或声明为抽象
public static void main(String[] args);
我是 Java 新手。
英文:
/* =================================================
* Name: Kaleb Prichard
* ID #: 140289
* Section: CS 202 - 1
* Program: 4
* ================================================= */
import java.util.Scanner;
public class fourthProgram
{
// This is where the program begins execution
public static void main(String[] args);
{
double mealCost, tax, mealCount, subtotal, total;
Scanner keyboard = new Scanner(System.in);
System.out.println("This program will display a receipt showing the subtotal, tax, and total cost of the purchase.");
System.out.println("How much does a MEAL COST ?");
mealCost = keyboard.nextDouble();
System.out.println("How many meals is the customer PURCHASING ?");
mealCount = keyboard.nextDouble();
subtotal = mealCost * mealCount;
tax = 7.5 * subtotal;
total = subtotal + tax;
System.out.print(total%5.2);
//TOTAL is in dollars
}
}
Every time I attempt to compile this code I receive an error saying:
> fourthProgram.java:13: error: missing method body, or declare abstract
public static void main(String[] args);
I am new to Java.
答案1
得分: 0
nextDouble()
方法区分大小写。注意大写的 D
。
英文:
nextDouble()
method is case sensitive. Notice the capital D
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论