这是我的代码:
import java.util.Scanner;
class CreatePurchase {
public static void main(String args[])
{
Purchase purchase=new Purchase();
Scanner s=new Scanner(System.in);
System.out.println("Enter the details: ");
while(true)
{
System.out.print("Enter invoice number[between 1000 and 8000]: ");
int i=s.nextInt();
if(i>=1000 && i<=8000){purchase.setInvoiceNumber(i);break;}
else System.out.println("Wrong entry,enter again");
}
while(true)
{
System.out.print("Enter amount of purchase[should be non-negative]: ");
int i=s.nextInt();
if(i>=0){purchase.setAmountOfSales(i);break;}
else System.out.println("Wrong entry,enter again");
}
purchase.display();
}
}
这是我不断收到的确切错误消息:
C:\Users\Kenneth\Documents\NetBeansProjects\CreatePurchase\src\createpurchase \CreatePurchase.java:9: error: cannot find symbol
Purchase purchase=new Purchase();
symbol: class Purchase
location: class CreatePurchase
C:\Users\Kenneth\Documents\NetBeansProjects\CreatePurchase\src\createpurchase\CreatePurchase.java:9: error: cannot find symbol
Purchase purchase=new Purchase();
symbol: class Purchase
location: class CreatePurchase
2 errors
我不知道如何修复它,netbeans 没有显示代码有任何问题。帮助表示赞赏。
这是购买代码,它编译并运行良好。
class Purchase
{
int invoiceNumber;
int amountOfSales;
double amountOfSalesTax;
static double rate=7.5;
public void setInvoiceNumber(int i)
{
invoiceNumber=i;
}
public void setAmountOfSales(int a)
{
amountOfSales=a;
amountOfSalesTax=(7.5*a)/100;
}
public void display()
{
System.out.println("The deatils are:");
System.out.println("Invoice Number: "+invoiceNumber);
System.out.println("Amount of Sales: "+amountOfSales);
System.out.println("Amount of sales tax: "+amountOfSalesTax);
}
}