Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I would like someone to program this assignment but follow the following steps b

ID: 3554039 • Letter: I

Question

I would like someone to program this assignment but follow the following steps because they are required! Shows all steps for all points in return!!!!! I am not looking for the first right answer....I am looking for the best answer!



This assignment should use the concepts, Java implementations, and applications of the following:

Class inheritance
    Polymorphism
    File I/O and arrays
    Exceptions

Design a Java application to emulate operations at a grocery store that sells 3 kinds of Items/Products: Dairy, Vegi and Meat. The user may log in as a Manager or a Client.

A Manager has access to the Inventory which must be an Array of at least 10 Items and can list, add, delete or modify Items at the store. A client shops at the store by editing his Shopping Cart which can also be an Array of Items. A client can choose to open his old Shopping Cart and continue shopping or start a new one. After a client checks out, his Shopping Cart can be cleared and a receipt must be printed, which shows details of all the purchased Items. Both Inventory and a Client's Shopping Cart have to be also kept updated in files.

Each Item/Product at the store has the following data:

    name
    itemCode: first part indicates the Item's category; second part indicates the brand
    unitPrice
    totalQuantity

Each Dairy item also includes data for amount of fat; Vegi also includes amount of fiber; Meat also includes amount of protein.

The program must include the following classes:

    Item
    Dairy
    Vegi
    Meat
    Inventory
    ShoppingCart

Dairy, Vegi and Meat must inherit Item.

Any error in the program must throw an exception.

Explanation / Answer

I coded the problem in eclipse. And this works perfectly.
There is no option of attaching zip in Chegg.

So I am pasting the code here.


Specification of the code:-

Each product is assigned an ID.

You can insert, remove, search for a product.

You may print the whole bunch of products available at the grocery store.

COPY THE FOLLOWING CODE AND run it. If some problem occurs, please ask me. Hope this helps. All the best :)


package chegg_grocery_java;

import java.io.*;


public class chegg_grocery_java {


public static void main(String[] args) {

BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

String[] initial_elements = {"Toordal","Carrot", "Tomato"};

DS4 store = new DS4(initial_elements);

int id,num;


while(true) {

try {

System.out.println("");

System.out.println("1: Insert");

System.out.println("2: Remove");

System.out.println("3: Search");

System.out.println("4: Print Tree");

System.out.println("Enter command number:");

num = Integer.parseInt(stdin.readLine());

switch(num) {

case 1:

System.out.println("Enter Product:");

String product = stdin.readLine();

id = store.insert(product);

System.out.println("ID assigned:"+id);

break;

case 2:

System.out.println("Enter ID:");

id = Integer.parseInt(stdin.readLine());

String removed_element = store.remove(id);

System.out.println("Product removed:"+removed_element);

break;


case 3:

System.out.println("Enter ID:");

id = Integer.parseInt(stdin.readLine());

String element = store.get(id);

System.out.println("Product searched:"+element);

break;


case 4:

System.out.println("Product Tree:");store.inorder();

break;


default:

throw new Exception();

}

}

catch (Exception e)

{

System.out.println("Wrong Input Entered");

}

}

}


}