问题描述:

Here is my code:

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();

}

}

This is the exact error messages I keep getting:

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

I have no idea how to fix it and netbeans is not showing anything wrong with the code. Help is appreciated.

Here is the Purchase code, which compiled and ran fine.

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);

}

}

相关阅读:
Top