Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment task

Write a java console application that allows the user to keep track of various items in a grocery shop. The application must allow the user to read, validate, store, display, sort and search the item name (String), item id (integer number), quantity of the item in-stock (integer number), factory price (double number) and shop price (double number) for N items in the grocery shop. N should be declared as a constant and it should be equal to the largest digit of your student id number (e.g. if your ID number is S0234111 then N should be equal to 4 and you can declare it as final int N=4;). The item name, item id, quantity of the item in-stock, factory price and shop price must be stored in five separate single dimension Arrays/ArrayLists (index 0 for item 1 and index N-1 for item N). The minimum and maximum id numbers which can be stored are 1 and 333. The minimum and maximum factory prices for each item which can be stored are $1 and $1000. The item id and factory price must be entered from the keyboard and a validation for minimum and maximum values must be done.

Your application should display and execute a menu with the following options. A switch statement must be used to execute the following menu options.

1. Read, validate and store all items
2. Calculate and store shop price for all items
3. Display all items
4. Sell an item
5. Display all items with the lowest factory price
6. Sort and display sorted items
7. Exit from the application

1. Read, validate and store all items
This option reads item name, item id, quantity of the item in-stock and factory price for N items from the keyboard and stores them in four separate single dimension Arrays/ArrayLists. If the id number is less than 1 and greater than 333 then an appropriate message should be displayed and the user should be asked to enter a new id number. Similarly if the factory price is less than $1 and greater than $1000 then an appropriate message should be displayed and the user should be asked to enter a new price.

2. Calculate and store shop price for all items
This option asks user to enter the discount percentage (e.g. 5%), calculates the shop price for each item and then stores shop price in fifth Array/ArrayList.

3. Display all items
Display all information (item name, item id, quantity of the item in-stock, factory price and shop price) for each item in the shop.

4. Sell an item
This option asks user to enter item id, searches for that item id and quantity of the item in-stock. If item is found and the quantity of items in-stock is not 0 then it displays a message "item sold" and decreases the quantity of items in-stock by one for that item. If item is not found or item found but

the quantity of items in-stock is 0 then it displays a message "item is not in-stock". A built-in search algorithm for searching can be used in this assignment.

5. Display all items with the lowest factory price
This option finds and displays the item in Array/ArrayList which has the lowest price. If there is more than one item with the lowest price then it displays all of them.

6. Sort and display sorted items
This option sorts (by item name) all items stored in Array/ArrayList in descending order and displays all sorted items (item name, item id, quantity of the item in-stock, factory price, shop price). You can use any sorting algorithm. A built-in sort algorithm for sorting is not allowed in this assignment.

7. Exit from the application
The application should display the message an appropriate message with your student id and then exit from the application.

The application should work in a loop to enable the user to Read, validate and store all items, Calculate and store shop price for all items, Display all items, Sell an item, Display all items with the lowest factory price, Sort and display sorted items and Exit from the application.

Program design
You may use any design that meets the specification. However, a good design will adhere to the following guidelines:
- be logically correct
- be easy to read and maintain
- be well-designed
- use a UML activity diagram
- use appropriate classes, methods and fields

Your design MUST use the classes and methods as listed below. public class GroceryShop
{
//fields
//get and set methods
}
public class GroceryShopTest
{
Method to read, validate and store all items
Method to calculate and store shop price for all items Method to display all items
Method to sell an item
Method to display all items with the lowest factory price Method to sort and display sorted items
Method to exit from the application

public static void main(String[] args)
{
}
}
You may add/use other methods, parameters, fields/variables, constants, etc. which you need to complete the application.

Testing

Testing is important. You should:
- List the different types of test cases.
- Display the results for each test case.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92470335
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Identify at least two 2 factors that have led to the

Identify at least two (2) factors that have led to the explosive growth of digital crime over the past a few decades. Next, describe the most common forms of digital crime, and give your opinion as to why those forms you ...

Come with an app that only runs in horizontal orientation

Come with an app that only runs in horizontal orientation. It displays "This is fun!" on the top left corner of the screen with no margin either from the top or the left.

If a wooden car has 30 independent components that all must

If a wooden car has 30 independent components that all must function for the wooden car to operate successfully during a race, and the probability of successful operation for any single component is 0.999, what is the pr ...

Suppose a soft drink company want to perform a taste test

Suppose a soft drink company want to perform a taste test on 5 brands of diet cola. How many permutations are there for presenting 5 diet colas to test subjects?

Answer the following question what is the relationship

Answer the following Question : What is the relationship between a role and a competency? How do roles facilitate the development and implementation of specific practices for any organization? The response must be typed, ...

If the annualized five-year rate of return is 15 and if the

If the annualized five-year rate of return is 15%, and if the first year's rate of return is 20%, and if the returns in all other years are equal, what are they? Provide the answer in % with four decimal places without r ...

Question using a web browser perform some research on a

Question: Using a Web browser, perform some research on a newer malware variant that has been reported by a major malware containment vendor. Using a search engine, go to the vendor's Web site; this could be Symantec, Mc ...

In a software design meeting in your company your manager

In a software design meeting in your company, your manager says that one of the most important engines of the Record Keeping System you are developing is the Index Sorting Engine. Your coworker quickly jumps in and says ...

Question part 1 analyze the case study titled vodafone a

Question: Part 1: Analyze the case study titled "Vodafone: A Giant Global ERP Implementation" (below) For this assignment, you will need to: 1. analyze and discuss the central issue(s) faced by Vodafone, including the co ...

A chemistry student needsnbsp150 ml of acetone for an

A chemistry student needs 15.0 mL of acetone for an experiment. By consulting the  CRC Handbook of Chemistry and Physics , the student discovers that the density of acetone is 0.790 g.cm^-3. Calculate the mass of acetone ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As