Knowee
Questions
Features
Study Tools

Develop a java application to handle the menu details of Sandy Food Inc. Company. Your application will handle the Sandwich product details. There are three types of Sandwiches under Sandwich class, they are Sweet, Sour, Hot. Each has two sub types of Sandwiches like small and medium. The members are ProductName – String (Sweet Small / Sweet Medium / Sour Small…) Price – Integer ProductCode - Integer GetOrder() - method to get the Product code and number of quantities. DisplayPrice() - method to display the Product name, number of quantities and cost. Your application should calculate the cost of the ordered product based on the quantity and price. Single order will not have more than one type of product. The price range of different products with the product code and product name are tabulated below. S.No Product name Product Code Price 1 Sweet Small 101 100/- 2 Sweet Medium 102 150/- 3 Sour Small 103 150/- 4 Sour Medium 104 200/- 5 Hot Small 105 200/- 6 Hot Medium 106 250/- Ensure that the bill value is calculated only on the respective class. The inputs are the product code and the quantity of the product. The expected output is the product name, quantity and price. If the entry is wrong product code, then handle with exception and display the message as “Invalid”.

Question

Develop a java application to handle the menu details of Sandy Food Inc. Company. Your application will handle the Sandwich product details. There are three types of Sandwiches under Sandwich class, they are Sweet, Sour, Hot. Each has two sub types of Sandwiches like small and medium. The members are

ProductName – String (Sweet Small / Sweet Medium / Sour Small…) Price – Integer ProductCode - Integer GetOrder() - method to get the Product code and number of quantities. DisplayPrice() - method to display the Product name, number of quantities and cost. Your application should calculate the cost of the ordered product based on the quantity and price. Single order will not have more than one type of product. The price range of different products with the product code and product name are tabulated below.

S.No

Product name

Product Code

Price

1

Sweet Small

101

100/-

2

Sweet Medium

102

150/-

3

Sour Small

103

150/-

4

Sour Medium

104

200/-

5

Hot Small

105

200/-

6

Hot Medium

106

250/-

Ensure that the bill value is calculated only on the respective class. The inputs are the product code and the quantity of the product. The expected output is the product name, quantity and price. If the entry is wrong product code, then handle with exception and display the message as “Invalid”.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a simple Java application that meets the requirements:

import java.util.*;

class Sandwich {
    String ProductName;
    int Price;
    int ProductCode;

    Sandwich(String ProductName, int Price, int ProductCode) {
        this.ProductName = ProductName;
        this.Price = Price;
        this.ProductCode = ProductCode;
    }

    void GetOrder(int ProductCode, int quantity) {
        this.ProductCode = ProductCode;
        this.Price *= quantity;
    }

    void DisplayPrice() {
        System.out.println("Product Name: " + this.ProductName);
        System.out.println("Price: " + this.Price);
    }
}

public class Main {
    public static void main(String[] args) {
        Sandwich sweetSmall = new Sandwich("Sweet Small", 100, 101);
        Sandwich sweetMedium = new Sandwich("Sweet Medium", 150, 102);
        Sandwich sourSmall = new Sandwich("Sour Small", 150, 103);
        Sandwich sourMedium = new Sandwich("Sour Medium", 200, 104);
        Sandwich hotSmall = new Sandwich("Hot Small", 200, 105);
        Sandwich hotMedium = new Sandwich("Hot Medium", 250, 106);

        List<Sandwich> sandwiches = Arrays.asList(sweetSmall, sweetMedium, sourSmall, sourMedium, hotSmall, hotMedium);

        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the product code:");
        int productCode = scanner.nextInt();
        System.out.println("Enter the quantity:");
        int quantity = scanner.nextInt();

        boolean isValid = false;
        for (Sandwich sandwich : sandwiches) {
            if (sandwich.ProductCode == productCode) {
                isValid = true;
                sandwich.GetOrder(product

This problem has been solved

Similar Questions

write a java program to define a class Item having item namepricequantityfind the total cost of the itemuse accept method to get the data from the user and toString method to display the detailscreate two objects and display the name of the item which is ordered more quantitydisplay total amount of items purchased.edited 10:37 AM

Explain the following types of menu pricing methods: i. Subjective pricing (5 marks) ii. Desired food cost percentage pricing (5 marks) iii. Profit pricing (5 marks) iv. Competition and pricing (5 mark

you are tasked with developing a canteen management system for a university campus. The canteen offers three main categories of items: snacks, beverages, and meals. Each category has specific attributes. Using classes, objects, function overloading, constructors, and access specifiers, create a system that allows the user to add and display details of items available in the canteen, including their quantity.Instructions:Implement three classes: Snack, Beverage, and Meal.Each class should have private attributes for storing item details, including name, price, quantity, expiration date, and additional attributes specific to each category.Overload constructors for each class to initialize objects with different sets of parameters.Create functions to add and display details of items in the canteen.Sample InputEnter Snack Details:Name: CookiesPrice: 1.5Quantity: 100Expiration Date: 2024-05-31Enter Beverage Details:Name: LemonadePrice: 1.25Quantity: 75Expiration Date: 2024-06-15Volume: 16 ozType: Soft DrinkEnter Meal Details:Name: SpaghettiPrice: 10.75Quantity: 50Expiration Date: 2024-05-20Ingredients: Pasta, Tomato Sauce, MeatballsCooking Time: 45 minutesType: DinnerSample OutputCanteen Items Details:Snack Details:Name: CookiesPrice: $1.5Quantity available: 100Expiration Date: 2024-05-31Beverage Details:Name: LemonadePrice: $1.25Quantity available: 75Expiration Date: 2024-06-15Volume: 16 ozType: Soft DrinkMeal Details:Name: SpaghettiPrice: $10.75Quantity available: 50Expiration Date: 2024-05-20Ingredients: Pasta, Tomato Sauce, MeatballsCooking Time: 45 minutesType: Dinner

Happy Mart is a supermarket with wide range of products. The manager wants to add the products and sort them based on id and price. As a java developer, create a java application to sort the products based on id and price.Component Specification: ProductType (Class)AttributesMethodsProductint productidString productNamedouble priceInclude a public parametrized constructor of three  arguments in the following order - productId, productName and price to intialize the values for the Product object. Note: The class and constructor and all the attributes should be declared as public. Component NameType (Class)MethodsResponsibilitiesOverride the toString methodProductPublic String toString()This method should return String by overriding the productid, productName and price with space.Component Specification: SortByIdType (Class)MethodsResponsibilitiesSortByIdpublic int compare(Product a, Product b)This method should return the difference between productId of the object a and object bNote: This class implements the comparator interface of type Product.Component Specification: SortByPriceType (Class)MethodsResponsibilitiesSortByPricepublic int compare(Product a, Product b)This method should return the difference between price of the object a and object bNote: This class implements the comparator interface of type Product.In the UserInterface class,-       Get the products count from user. If the count is negative or zero, display "Invalid count".-       Get the product details as shown in the sample input.-       Create an object for each product and assign the values through 3 argument constructor.-       Get the choice from user as given in the sample input.-       Based on the choice entered, the corresponding comparator is invoked in sort method and the output is displayed as given in sample output.-       If the choice is other than 1 or 2, display "Invalid choice". Note:In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given by the user and the rest of the text represents the output. Ensure to follow the object-oriented specifications provided in the question. Ensure to provide the names for classes, attributes, and methods as specified in the question. Adhere to the code template, if provided. Please don't use System.exit(0) to terminate the program.  Sample Input/Output 1:Enter the products count3Enter Product details1006:Pen:501009:Eraser:401004:Ruler:401.Sort By Id2.Sort By PriceEnter your choice1After Sorting By Id1004 Ruler 40.01006 Pen 50.01009 Eraser 40.0 Sample Input/Output 2:Enter the products count4Enter Product details2503:Onion:802508:Tomato:502501:Carrot:1402506:Potato:1201.Sort By Id2.Sort By PriceEnter your choice2After Sorting By Price2508 Tomato 50.02503 Onion 80.02506 Potato 120.02501 Carrot 140.0 Sample Input/Output 3:Enter the products count2Enter Product details4002:Bread:2404006:Biscuit:1601.Sort By Id2.Sort By PriceEnter your choice5Invalid choice Sample Input/Output 4:Enter the products count-5Invalid count

To determine a product selling price based on the total cost method, management should include:Multiple ChoiceTotal product and selling, general, and administrative costs plus a markup.Total product and selling, general, and administrative costs only.Total product costs plus a markup.Total selling, general, and administrative costs plus a markup.Only a markup.

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.