/* =================================================
* 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
}
}
每次我试图编译这个代码时,我都会收到一个错误,上面写着:
fourthProgram.java:13:错误:缺少方法体,或声明抽象public static void main(String[]args(;
我是Java新手。
nextDouble()
方法区分大小写。注意大写D
。