Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6713323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:21:59+00:00 2026-05-26T08:21:59+00:00

The below is a test code where I am getting an error Pizza order

  • 0

The below is a test code where I am getting an error Pizza order = new Pizza(); I believe that I didn’t import Pizza.class to Pizzaorder.class file. Can anybody help me in fixing this error.

Code follows.

Pizza.java

package pizza;
public class Pizza {
        private double cost; //the cost of the pizza
    private String crust; //the type of crust
    private int size; //the diameter in inches
    private int numToppings; //the number of toppings
    private String toppingList; //a list of the toppings
    public static void main(String[] args) {
    }
    public Pizza()
    {
        cost = 12.99;
        crust = "Hand-tossed";
        size = 12;
        numToppings = 0;
        toppingList = null;
    }
    public void setCost (double amount)
        {
            cost += amount;
        }
    public void setCrust (String type)
    {
        crust = type;
    }
    public void setSize (int diameter)
    {
        size = diameter;
    }
    public void setNumToppings(int number)
    {
        numToppings = number;
    }
    public void setToppingList (String newTopping)
    {
        toppingList = newTopping;
    }
    public double getCost()
    {
        return cost;
    }
    public String getCrust()
    {
        return crust;
    }
    public int getSize()
    {
        return size;
    }
    public int getNumToppings()
    {
        return numToppings;
    }
    public String getToppingList()
    {
        return toppingList;
    }
}

PizzaOrder.java

package pizza;
import java.util.Scanner;
public class PizzaOrder {
    public static void main (String [] args)
    {
                Scanner keyboard = new Scanner (System.in);
                Pizza order = new Pizza ();
                String firstName;
        boolean discount = false;
                int inches; 
        char crustType; 
        double cost; 
        final double TAX_RATE = .08;
        double tax;
        char choice; 
        String input;
        String toppings = "Cheese ";
        int numberOfToppings = 0;
        System.out.println("Welcome to Abdul and " +
        "Diane’s Pizza");
        System.out.print("Enter your first name: ");
        firstName = keyboard.nextLine();
        System.out.println("Pizza Size (inches)     Cost");
        System.out.println("        10          £10.99");
        System.out.println("        12          £12.99");
        System.out.println("        14          £14.99");
        System.out.println("        16          £16.99");
        System.out.println("What size pizza would you like?");
        System.out.print("10, 12, 14, or 16 " + "(enter the number only): ");
        inches = keyboard.nextInt();
        keyboard.nextLine();
        System.out.println("What type of crust do you want? ");
        System.out.print(
        "(H)Hand-tossed, (T) Thin-crust, or " +
        "(D) Deep-dish (enter H, T, or D): ");
        input = keyboard.nextLine();
        crustType = input.charAt(0);
                System.out.println("All pizzas come with cheese.");
        System.out.println(
        "Additional toppings are £1.25 each,"
        + " choose from");
        System.out.println(
        "Pepperoni, Sausage, Onion, Mushroom");
        System.out.print("Do you want Pepperoni? (Y/N): ");
        input = keyboard.nextLine();
        choice = input.charAt(0);
        if (choice == 'Y' || choice == 'y')
        {
            numberOfToppings += 1;
            toppings = toppings + "Pepperoni ";
        }
        System.out.print("Do you want Sausage? (Y/N): ");
        input = keyboard.nextLine();

        choice = input.charAt(0);
        if (choice == 'Y' || choice == 'y')
        {
            numberOfToppings += 1;
            toppings = toppings + "Sausage ";
        }
        System.out.print("Do you want Onion? (Y/N): ");
        input = keyboard.nextLine();

        choice = input.charAt(0);
        if (choice == 'Y' || choice == 'y')
        {
            numberOfToppings += 1;
            toppings = toppings + "Onion ";
        }
        System.out.print("Do you want Mushroom? (Y/N): ");
        input = keyboard.nextLine();
        choice = input.charAt(0);
        if (choice == 'Y' || choice == 'y')
        {
            numberOfToppings += 1;
            toppings = toppings + "Mushroom ";
        }
        order.setNumToppings (numberOfToppings);
        order.setToppingList(toppings);
        order.setCost(1.25*numberOfToppings);
        System.out.println();
        System.out.println("Your order is as follows: ");
        System.out.println(order.getSize() + " inch pizza");
        System.out.println(order.getCrust() + " crust");
        System.out.println(order.getToppingList());
        cost = order.getCost();
                System.out.println("The cost of your order is: £" +
        cost);
        tax = cost * TAX_RATE;
        System.out.println("The tax is: £" + tax);
        System.out.println("The total due is: £" +
        (tax+cost));
        System.out.println("Your order will be ready" +
        " for pickup in 30 minutes.");
    }
}

Error:

C:\Users\Meutex\Documents\Netbeans projects>javac PizzaOrder.java
PizzaOrder.java:23: error: cannot find symbo

Additional error.

C:\Users\Meutex\Documents\Netbeans projects\Pizza>java Pizza.PizzaOrder
Exception in thread "main" java.lang.NoClassDefFoundError: Pizza/PizzaOrder (wro
ng name: pizza/PizzaOrder)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:472)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:22:00+00:00Added an answer on May 26, 2026 at 8:22 am

    The problem is that you’re not compiling both files.

    Change javac PizzaOrder.java to be javac PizzaOrder.java Pizza.java

    Edit:

    To run your program, put PizzaOrder.class and Pizza.class in a directory called pizza. From the parent directory of pizza run java pizza.PizzaOrder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the code below gives compilation error when I try to create test t[2]; because
The code is as below: <html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class=margin> </span><span>male</span></div> </body>
Im getting an error using this code below. I have tried multiple ways and
I am getting the following error when using the code below the error. can
I have the code below in my test code in many places: // //
The code looks like below: namespace Test { public interface IMyClass { List<IMyClass> GetList();
In the below code onclick edit how can the value of tag test be
When I run a Test Project on Visual Studio I use the code below
I'm getting error C3095: 'Xunit::Extensions::InlineDataAttribute': attribute cannot be repeated in C++/CLI code but not
I am getting the following error when trying to use the WCF Test Client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.