Write a java console application

Assignment Help Computer Engineering
Reference no: EM131661633

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.

Verified Expert

This assignment contains 2 java classes and report.docx. One java class "GroceryShop.java" is used to store the items and other one "GroceryShopTest.java" : test the functionality like add the item, selling of item, sorting the item on the basis of item name, display the item having the lowest factory price etc. and the report.docx contains the test cases with snapshot of output of test cases along with URL activity diagram of sell item

Reference no: EM131661633

Questions Cloud

Describe the circumstances and the outcome : Relate some experience where bargaining was useful and describe the circumstances and the outcome for both parties.
Makes the widgets is world wide widgets : Assume that you (Widget World) wish to purchase 1000 Widgets. The company that makes the Widgets is "World Wide Widgets."
Journalize the entry on july : For Blossom Co., journalize the entry on July 1 and the adjusting entry on December 31
Six sigma is deployed using the define-measure-analyze : Six Sigma is deployed using the Define-Measure-Analyze-Improve-Control (DMAIC) project management framework.
Write a java console application : Write a java console application that allows the user to keep track of various items in a grocery shop - Calculate and store shop price for all items
What is the impact on price and quantity : Does your event impact demand, supply, elasticity of demand? all of the above? How? What is the impact on price and quantity?
What is the expected value of the building : Given the chances of an earthquake, what is the expected value of the building?
What would be the amount of cost allocated to department : If these costs are budgeted at $55,421 during a given period, what would be the amount of cost allocated to Department B under the direct method
Demonstrate logical thinking in analysis of nursing theory : Examine instances where theory is used to guide the development of new knowledge or implementation of evidence-based practice

Reviews

inf1661633

12/29/2017 5:29:12 AM

Thanks for the solution and following the correct sorting. I wanted sorting manually only but I was not aware earlier, but thanks for your attention. I will come back soon with new assignments.

inf1661633

12/29/2017 5:26:59 AM

hey, thnks for the assignment. it looks good till now. but i came to know today that for the sorting we should not use built-in methods and do the sorting manually. can u make sure of this requirement please. other there is no issue.

inf1661633

12/29/2017 5:26:32 AM

regarding the assignment it says the constant value N should be the highest digit from my student ID. my student ID is so the value of N is 7 in my case. please keep in point no Word Limit the report would have test cases for valid and invalid input and the UML diagram and all the coding would have a clear count for every linewith short description comment handling exception holding should be done well.

len1661633

9/28/2017 1:26:36 AM

no Word Limit the report would have test cases for valid and invalid input and the UML diagram and all the coding would have a clear count for every linewith short description comment handlingexception holding should be done well

len1661633

9/28/2017 1:26:15 AM

3 Report – 2 Presentation (fonts, spaces, information, language) 2 4 Penalty Penalty for submission of incorrect files including names and formats is 2 marks Penalty for late submission is 5% mark / day or part of a day

len1661633

9/28/2017 1:26:09 AM

2 Compilation and execution - 14 (0 - if application doesn't run) Welcome and exit messages 1 Input data validation and message 1 Read and store all items 1 Calculate and store shop price for all items 2 Display all items 1 Sell an item 2 Display all items with the lowest factory price 2 Sort and display sorted items 2 Overall program execution (user friendly, input/output and display) 2

len1661633

9/28/2017 1:26:01 AM

Assessment 2 marking criteria Total Marks – 30 Marks Allocated 1 Design, logic and testing – 14 Code readability – appropriate use of comments, indentation and naming conventions 3 Declaring and using fields/variables and constants 2 Creating/declaring and using objects, methods and classes 3 Overall design and logic (structure, efficiency) 2 Validity of testing as evidenced by submitted test results 2 UML activity diagram for menu option 4 2

len1661633

9/28/2017 1:25:42 AM

Testing Testing is important. You should: • List the different types of test cases. • Display the results for each test case. What to submit You should submit online the following files. • GroceryShop.java (this file contains java code for class GroceryShop) • GroceryShopTest.java (this file contains java code for class GroceryShopTest). • Report.docx (this file contains a brief report that includes student name, student ID, course name, course code, UML activity diagram for menu option 4 (Sell an item) and test results (screenshots/test cases with results to show that your application is correctly working)).

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd