Java错误:编译时找不到符号

huangapple go评论75阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年10月19日 03:02:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/64417223.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定