the error and the class http://puu.sh/1ITnS.png爪哇 - “错误:无法找到或加载主类”错误
当我命名类文件Main.class,java的说,它的名称有误,当我将其命名为shop.Main.class它说主要的课程无法找到。谁能帮忙?
package shop;
import java.text.DecimalFormat;
public class Main
{
public static void main(String args[])
{
Cart cart = new Cart(new Catalogue());
printOrder(cart);
}
public static void printOrder(Cart cart)
{
DecimalFormat df = new DecimalFormat("0.00");
System.out.println("Your order:");
for(int itemIndex = 0; itemIndex < cart.itemsInCart.products.size();
itemIndex++)
if (cart.itemsInCart.products.get(itemIndex).quantity != 0)
System.out.println(cart.itemsInCart.products.get(itemIndex).quantity
+ " " + cart.itemsInCart.products.get(itemIndex).name
+ " $"+ df.format(cart.itemsInCart.products.get(itemIndex).price)
+ " = $" + df.format
((cart.itemsInCart.products.get(itemIndex).quantity
* cart.itemsInCart.products.get(itemIndex).price)));
double subtotal = 0;
int taxPercent = 20;
double tax;
double total;
for(int itemIndex = 0; itemIndex < cart.itemsInCart.products.size();
itemIndex++)
subtotal += cart.itemsInCart.products.get(itemIndex).quantity
* cart.itemsInCart.products.get(itemIndex).price;
tax = subtotal * taxPercent/100;
total = subtotal + tax;
System.out.print("Subtotal: $" + df.format(subtotal)
+ " Tax @ " + taxPercent + "%: $" + df.format(tax)
+ " Grand Total: $" + df.format(total));
}
}
以下两行之间忽略
-------------------------
编辑总结
糟糕!您的编辑无法提交,因为:
您的帖子没有太多的上下文来解释代码段;请更清楚地解释你的情况。
取消
-------------------------
Java教程可以帮助
你的例子会工作。 –
显示你的'main'代码 – codeMan
要么删除'包店;从'java'文件夹 –