Developing A Java Application For A Flower Shop Order Management System
Task 1 (System Design and Initial Implementation)
1) Flowchart and Pseudo-code:
Flowchart:
Figure 1: Flow Chart
(Source: Self created in draw.io)
Pseudo-code:
BEGIN
WHILE true
CALL displayMenu()
READ choice
IF choice == 1 THEN
CALL orderDetailsAndPriceCalculation()
ELSE IF choice == 2 THEN
CALL summaryStatistics()
ELSE IF choice == 3 THEN
PRINT "Exiting the program..."
EXIT program
ELSE
PRINT "Invalid choice. Please select 1, 2, or 3."
END IF
END WHILE
END
a)Input Validation and Error Checking:
Another important decision structure implemented by the application is the switch statement to check the input(Syaifudin et al. 2021). An error message is displayed if the user enters an option other than the three acceptable ones which are 1, 2, and 3. Since the choice variable is gone up by an integer, menu selection is appropriate(Syaifudin et al. 2020). Possible issues of entering non-integer values are thus eliminated when using an integer.
b) Conventions and Formatting:
The pseudo-code follows standard conventions with capitalized keywords, proper indentation for structures and names for methods(displayMenu, orderDetailsAndPriceCalculation and summaryStatistics).
c) Method Execution:
The program executes the appropriate method based on user input. When option 1 is selected, it calls orderDetailsAndPriceCalculation(). When option 2 is selected, it calls summaryStatistics().
d) Basic Method Implementation:
public static void orderDetailsAndPriceCalculation() {
String[] flowerTypes = {"Rose", "Lily", "Carnation", "Daffodil", "Gerbera", "Chrysanthemum", "Assorted"};
String[] colorTypes = {"White", "Red", "Pink", "Yellow", "Blue", "Assorted"};
String[] sizeTypes = {"Small", "Medium", "Large"};
double[] flowerPrices = {1.2, 1.3, 1.0, 1.0, 1.1, 1.1, 0.8};
double[] colorPrices = {1.3, 1.2, 1.1, 1.1, 1.2, 1.0};
double[] sizePrices = {5.5, 7.5, 9.5};
// Display and get flower choice
System.out.println("Select flower type:");
for (int i = 0; i < flowerTypes.length; i++) {
System.out.println((i + 1) + ". " + flowerTypes[i]);
}
int flowerChoice = getValidInput(1, flowerTypes.length) - 1;
// Display and get color choice
System.out.println("Select flower color:");
for (int i = 0; i < colorTypes.length; i++) {
System.out.println((i + 1) + ". " + colorTypes[i]);
}
int colorChoice = getValidInput(1, colorTypes.length) - 1;
// Display and get size choice
System.out.println("Select bouquet size:");
for (int i = 0; i < sizeTypes.length; i++) {
System.out.println((i + 1) + ". " + sizeTypes[i]);
}
int sizeChoice = getValidInput(1, sizeTypes.length) - 1;
// Calculate price
double price = (flowerPrices[flowerChoice] + colorPrices[colorChoice]) * sizePrices[sizeChoice];
// Store order details
orders[orderCount++] = new Order(flowerTypes[flowerChoice], colorTypes[colorChoice], sizeTypes[sizeChoice], price);
System.out.println("The price of the bouquet is: " + price);
}
public static void summaryStatistics() {
if (orderCount == 0) {
System.out.println("No orders yet.");
return;
}
Code for two methods of implementation
(Source: Self-created in VS Code)
The first method performs the bouquet ordering process by providing the user choices with respect to the type of flower, color, size, etc, collects the choices, calculates the price with the help of arrays of prices and stores the order details(Sharopova 2024). The final offer of the price is made to the user. There is a starting check to see if there are any orders, but summaryStatistics() method is only part way done. There are some conditions, for example, if there are no orders then it will print out “No orders yet”.
2) Screenshot for taking user input
import java.util.Scanner;
import java.util.InputMismatchException;
public class FlowerShop {
static Scanner scanner = new Scanner(System.in);
static Order[] orders = new Order[100]; // Array to store orders
static int orderCount = 0; // Counter for the number of orders
Code for taking user input
(Source: Self-created in VS Code)
This code initializes a FlowerShop class with a Scanner for input and an Order array to store up to 100 bouquet orders.
3)Testing and Screenshots:
Figure 2: Output of menu
(Source: Self-created in VS Code)
This image shows the menu of the flower shop. Where the user can see three options. From there user can choose options and place the order.
To test the program, run it and select each option:
Select option 1:
Figure 3: Output for printing order message after order
(Source: Self-created in VS Code)
The console output below shows the user interface where one is able to place a bouquet order. It has got numbered options in size, color and the type of flower(Christopher and Waworuntu 2021). The user makes selections (all are designated by “1” in this case) that represent small, white, and rose. The application computes and gives the bouquet price as 13. 75.
Figure 4: Output for choosing another flower
(Source: Self-created in VS Code)
After selecting the option 1 from flower shop menu the user will get to choose the flower type. Here the image shows the user select ‘Lily’ as flower type. Then the user can choose the flower colour. Here the user choose ‘red’ as a flower colour. Then the user can choose the size of the flower. Here the user choose ‘medium’ as the size of the flower bouquet.
Select option 2:
Figure 5: Output of “Summary Statistics” for Rose
(Source: Self-created in VS Code)
Here the user choose option 2 to see the output of summary statistics of two chosen flowers.
Figure 6: Output of “Summary Statistics” for Lily
(Source: Self-created in VS Code)
Here the user choose option 2 to see the output of summary statistics of two chosen flowers.
Figure 7: Output of “Summary Statistics” of two flowers
(Source: Self-created in VS Code)
This output displays the main menu of the flower shop application and the summary statistics after some orders have been placed. The options that are available are if user want to order a bouquet or see statistics or simply dismiss the window(Khoirom et al. 2020). The quantitative characteristics of the orders are also given in the given statistic’s section, including the number of ordered bouquets and the total bargaining price of all the bouquets, along with the minimum, maximum, and median prices.
Select option 3:
Figure 8: Output for printing “Exiting the program”
(Source: Self-created in VS Code)
This output displays the main menu of the flower shop application. Here the user chooses option 3 means ‘exit’ and prints the statement ‘Exiting the program’.
Select an invalid option:
Figure 9: Output for printing “Invalid Choice”
(Source: Self-created in VS Code)
If the user enters 4 which is not in the menu to choose from, the message “invalid choice” is printed. The interaction of the menu system is best illustrated by a flowchart and pseudo-code; the options for data types and error checking are also presented there(Vyas 2023). It follows all the formatting norms and code protocols, executes the method required according to the particular input of the user, and offers the user simple method codes whenever necessary(Papadakis 2020). The menu will remain on the screen, and will be repeated until the user clicks on exit using a while loop. As for several choices from the user, it employs switch instead of if-else for the quantity of variants as it is simpler to read and to modify. [Refer to Appendix 1].
Building a Java application for managing flower shop orders can streamline your business processes efficiently. By implementing methods such as order calculations, summary statistics, and user input validation, this system ensures that every order is tracked, and pricing is calculated accurately. Whether you're just starting or enhancing an existing system, this guide provides comprehensive insights. For professional assistance and further enhancements in your Java project, explore our assignment help for expert guidance and support.
Task 2 (Order Management and Method Development)
1) Flowchart and Pseudo-code:
Flowchart:
Figure 10: Flow Chart
(Source: Self created in draw.io)
Pseudo-code:
BEGIN orderDetailsAndPriceCalculation
DECLARE flowerTypes[], colorTypes[], sizeTypes[]
DECLARE flowerPrices[], colorPrices[], sizePrices[]
END
a) Input Validation:
The choices of flower type, color, and size are entered by the user and are managed by the application via the Scanner class. The call of the getValidInput() which is a utility function supervises to validate the input. In this technique a while loop is used to request the input until the correct input among the choices is entered. In the case of possible InputMismatchExceptions in the course of carrying out user inputs, the application employs the try-catch blocks as a form of input validation(Salama et al. 2020). Further, the adopted method also incorporates if statements (for instance, if (choice >= min && choice <= max)) to check if the input is within the limit is correct. To contain the textual descriptions of various flowers, their varieties, color and sizes, string arrays are utilized. Choices use integers (int) because data of this type consists of discrete values(Amasha et al. 2021). Prices require doubles because else decimals would not be taken into consideration .
b)The pseudo-code that nfollows standard conventions with proper indentation, capitalization of keywords, and variable names.
c) The user uses Scanner for input from keyboard.
d) Data structure for storing orders:
Creating a class 'Order' with fields: flowerType, colorType, size, price
User uses an array of Order objects to store multiple orders
2) A Java method ‘orderDetailsAndPriceCalculation’
public static void orderDetailsAndPriceCalculation() {
String[] flowerTypes = {"Rose", "Lily", "Carnation", "Daffodil", "Gerbera", "Chrysanthemum", "Assorted"};
String[] colorTypes = {"White", "Red", "Pink", "Yellow", "Blue", "Assorted"};
String[] sizeTypes = {"Small", "Medium", "Large"};
double[] flowerPrices = {1.2, 1.3, 1.0, 1.0, 1.1, 1.1, 0.8};
double[] colorPrices = {1.3, 1.2, 1.1, 1.1, 1.2, 1.0};
double[] sizePrices = {5.5, 7.5, 9.5};
// Display and get flower choice
System.out.println("Select flower type:");
for (int i = 0; i < flowerTypes.length; i++) {
System.out.println((i + 1) + ". " + flowerTypes[i]);
}
int flowerChoice = getValidInput(1, flowerTypes.length) - 1;
Code for creating an array
(Source: Self-created in VS Code)
This code image defines arrays and variables for a flower shop application. For the flower store application this following code image shows the defined arrays and variables. The various possibilities for flowers, colors, and sizes are stored in three String arrays that are created: These are the types of flowers, colors and sizes that exists are flowerTypes, colorTypes and sizeTypes. Additionally defined are three double arrays: contains the arrays, sizePrices, colorPrices, and flowerPrices. They equal the price for every choice from the respective categories. Next, the code is obtaining the user’s selected flower(Evans et al. 2023). It outputs "Select Flower type:Matches the string “ Hibiscus is one of the <number> types of flowers that beautify the world” and prints out numbered options for all types of flower using a for loop. Finally, it invokes the getValidInput function (not shown) to take the selection from the user and the input is transformed from 1-based array index to the 0-based array index by – 1. It is easy to extend this framework and add other options and their prices.
// Order class to represent each order
class Order {
private double price;
public Order(String flowerType, String flowerColor, String bouquetSize, double price) {
this.price = price;
}
public double getPrice() {
return price;
}
}
Code for creating order class
(Source: Self-created in VS Code)
The following picture show a Java class definition for an Order class. This struct is used to define the flower type, color, size and price in a particular order and, hence, is called the Order class. Its getPrice () function returns the price, and its constructors assign initial value to such values as the code and the name(Mekterović et al. 2020). The price attribute is a private encapsulated by the class, and a method function of public is assigned to it. It becomes possible to efficiently construct and manage private flower orders that contain specific data; thus a successful application of a flower shop can freely accommodate various order forms.[Refer to Appendix 2]
3) Including 5 additional bouquet orders
Figure 11: Output for creating additional 5 bouquet orders
(Source: Self-created in VS Code)
This output shows a flow in the ordering system for flowers, with the command-line interface. It presents menus in which the users are able to select type, color and size of the bouquet. For each category, the user is required to indicate his/her choices which have been numbered in order to ease on selection. Such an interface allows the customers to select the bouquet size such as small, medium, large and color such as white, red, pink, and the type of flowers like roses, lilies, carnations, and others.
4) Testing the program and screenshot
Figure 12: Output of printing the ordered bouquet(Carnation)
(Source: Self-created in VS Code)
This image shows the output of the flower ordering application in case of a bouquet that contains carnations. The user chooses size as large opting for Option 3, color as pink with Option 3, and the type of flowers as carnations with Option 3. After that, the application calculates as well as displays the bouquet of $19. 95 price(Muqorobin and Rais 2022). This explains the ability of the particular application to provide essential ordering information from the user inputs and offer the price information in real-time. It also makes the user experience better by informing the user feedback on the selections they made, such feedback is easy to understand.
Figure 13: Output of printing the ordered bouquet(Daffodil)
(Source: Self-created in VS Code)
This output image where the customer has ordered a bouquet of daffodils as indicated in the following output image. Option 3 large size of the bouquet is chosen by the user along with option 4 pertaining to the yellow flower color and option 4 regarding daffodil flower kind. The same as in the previous example, the software determines and shows the price for this scheme, which will be $19. 95. This shows how the program helps to price a number of flower species while the sizes of bouquets remain constant; the price is consequently going to be the same regardless of the type of flower included.
Task 3 (Generating Order Statistics and Data Analysis)
1)Flowchart and Pseudo-code:
Flowchart:
Figure 14: Flow Chart
(Source: Self created in draw.io)
Pseudo-code:
BEGIN summaryStatistics
INITIALIZE minPrice, maxPrice, totalPrice, totalBouquets
INITIALIZE sizeCount[], flowerCount[], colorCount[]
END
a) Input Validation:
Since the summaryStatistics of the database relies on already existing data, the method does not require the user’s input in the process(Kanika et al. 2020). However, the user must ensure that there exist orders to be fulfilled by the center through orderCount >0. For this type of concern, it is recommended that users use the double data type for price computations and int for counters as well as frequency counts. For frequency counts that relate to the research predetermined categories of sizes, blooms and color, arrays are employed.
b)The pseudo-code follows the conventions which are standard with proper indentation, capitalization of keywords, and variable/method(descriptive) names.
2) A Java method ‘summary statistics’
a) ‘SummaryStatistics’ method implementation
public static void summaryStatistics() {
if (orderCount == 0) {
System.out.println("No orders yet.");
return;
}
double[] prices = new double[orderCount];
double minPrice = Double.MAX_VALUE;
double maxPrice = Double.MIN_VALUE;
double totalPrice = 0;
for (int i = 0; i < orderCount; i++) {
double price = orders[i].getPrice();
prices[i] = price;
if (price < minPrice) minPrice = price;
if (price > maxPrice) maxPrice = price;
totalPrice += price;
}
double averagePrice = totalPrice / orderCount;
System.out.println("Minimum price: " + minPrice);
System.out.println("Maximum price: " + maxPrice);
System.out.println("Range of price: " + (maxPrice - minPrice));
System.out.println("Total number of bouquets ordered: " + orderCount);
System.out.println("Total price of all bouquets: " + totalPrice);
System.out.println("Average price of bouquet: " + averagePrice);
Code for using the ‘summary statistics’ method
(Source: Self-created in VS Code)
In the following picture code, the function summaryStatistics() defined is used to compute several statistics concerning flower bouquet orders. First, it seeks to check if there are orders that have been placed. Otherwise, it analyzes the prices of the orders and computes the minimum, maximum, and total prices. Besides, it calculates the average price, as well as the range(Kato and. These information, the total of ordered bouquets, the total cost of all the bouquets, the average cost of a bouquet, as well as the minimum and maximum cost of a bouquet are then printed by the technique. This provides a detailed overview of the flow of the sales, particularly concerning the order of the bouquets and the distribution of the prices for the flower business.
3)Testing and screenshot:
Figure 15: Sample Output for testing the given data(1st row)
(Source: Self-created in VS Code)
This console output shows how the application looks when the user is placing an order for the bouquets. In it user have numbered choices for size, color, and kind of flower. New selection is made by the user where the values are as: medium = 2, pink = 3, rose = 1. The price of the bouquet, worked out by the application and displayed on the layer, also equals 17.25.
Figure 16: Sample Output for testing the given data(2nd row)
(Source: Self-created in VS Code)
This console output demonstrates the order process for a flower bouquet. It demonstrates how to order a bouquet of flowers. The user is asked to choose three options: Some of the factors include; the type of flower which is usually Assorted, the color which can either be Assorted or Mixed, and the size which is often LargeIgarashi 2020). After these options, the application calculates the result and displays $17. 1 as the price of the bouquet. This cost of a large and diverse bouquet of constructively different flowers is equivalent to one of the sample data mentioned in the assignment. The steps to order flowers and the options to modify them are clearly broken down into simple stages, and the estimated price for the order is calculated immediately.
Figure 17: Sample Output for testing the given data(3rd row)
(Source: Self-created in VS Code)
The console outputs depict the user interface for placing a flower arrangement order. Instead of providing the texts to fill in, the application suggests the numbered options of the flower type, color, and size. In size, the user selects option 1 which is small, for color the user selects option 4 which is yellow, finally for the type of flower the user selects again option 4 which is daffodil. This one follows the previous ones as the application calculates and displays $12.1. It typically set at 1 as the price for the bouquet. Actually, through the usage of this UI, personalising a flower order is quite easy and hassle free. The user can read through the options because of their well arranged order that the author has placed them in. This means that the ordering process is enhanced through the real-time calculation of prices coupled with presentation immediately the user makes his or her orders. The order process has, therefore, been successful as dictated by the message: “A bouquet has been ordered”.
Figure 18: Sample Output for testing the given data(4th row)
(Source: Self-created in VS Code)
The ordering interface for flower bouquet is shown in this console output as the following is an example of the flower bouquet ordering interface. Here, the user prefers the second option, size, while color and flower kind are the first, and second options correspondingly. Finally, the application computes the bouquet and displays the flower price at $19.5 as the bouquet’s price. 5 after these options. Due to the different choices made especially conversion from small to the medium size of the bouquet, the total price for this order is greater than the previous one. This is an example illustrating how the application has a mechanism that can adapt to the user.
Figure 19: Sample Output for testing the given data(5th row)
(Source: Self-created in VS Code)
The console interface of the order system for a flower store is depicted in the output image. The menu list in the form of a message containing the names of flowers, which includes Rose, Tulips, Carnations and so on. The specifics of the flower and the size of the bouquet that has to be purchased are selected by the user. In this case, the user has opted for a bouquet of three numbers and choice number three, which seems to be the carnation. After then, the algorithm determines and displays the total cost price of the bouquet that is 22. 8.
Figure 20: Output for showing all the summary statistics
(Source: Self-created in VS Code)
This output image presents the flower bouquet orders aggregated in this output resembles the actual data. It shows important financial and order data: a bouquet cost a minimum of 12.1. to a maximum of 22.8, for a price of 10. 7. The output for this session was that 5 bouquets in all were ordered(Tupac-Yupanqui et al. 2022). Thus, if user divide the total price of all the bouquets by the number of bouquets user discern that the average price of one bouquet was 17. 75. Thus, the sum of prices for all the bouquets of the ordering was 88.75. This brief synopsis provides main information on the ordering activity and the specifics of the price fluctuations and gross quantity of sales.
Reference List
Journals
- Syaifudin, Y.W., Funabiki, N., Kuribayashi, M., Mentari, M., Saputra, P.Y., Yunhasnawa, Y. and Ulfa, F., 2021, February. Web application implementation of Android programming learning assistance system and its evaluations. In IOP Conference Series: Materials Science and Engineering (Vol. 1073, No. 1, p. 012060). IOP Publishing.
- Syaifudin, Y.W., Funabiki, N., Kuribayashi, M. and Kao, W.C., 2020. A proposal of Android programming learning assistant system with implementation of basic application learning. International Journal of Web Information Systems, 16(1), pp.115-135.
- Sharopova, M., 2024. JAVA PROGRAMMING IN THE LANGUAGE FLOWING INPUT AND RELEASE. Solution of social problems in management and economy, 3(1), pp.84-93.
- Christopher, L. and Waworuntu, A., 2021. Java programming language learning application based on octalysis gamification framework. IJNMT (International Journal of New Media Technology), 8(1), pp.65-69.
- Khoirom, S., Sonia, M., Laikhuram, B., Laishram, J. and Singh, T.D., 2020. Comparative analysis of Python and Java for beginners. Int. Res. J. Eng. Technol, 7(8), pp.4384-4407.
- Khoirom, S., Sonia, M., Laikhuram, B., Laishram, J. and Singh, T.D., 2020. Comparative analysis of Python and Java for beginners. Int. Res. J. Eng. Technol, 7(8), pp.4384-4407.
- Vyas, B., 2023. Security Challenges and Solutions in Java Application Development. Eduzone: International Peer Reviewed/Refereed Multidisciplinary Journal, 12(2), pp.268-275.
- Papadakis, S., 2020. Evaluating a game-development approach to teach introductory programming concepts in secondary education. International Journal of Technology Enhanced Learning, 12(2), pp.127-145.
- Vyas, B., 2023. Java-Powered AI: Implementing Intelligent Systems with Code. Journal of Science & Technology, 4(6), pp.1-12.
- Salama, R., Uzunboylu, H. and Alkaddah, B., 2020. Distance learning system, learning programming languages by using mobile applications. New Trends and Issues Proceedings on Humanities and Social Sciences, 7(2), pp.23-47.
- Amasha, M.A., Areed, M.F., Khairy, D., Atawy, S.M., Alkhalaf, S. and Abougalala, R.A., 2021. Development of a Java-based Mobile application for mathematics learning. Education and Information Technologies, 26, pp.945-964.
- Evans, B.J., Clark, J. and Flanagan, D., 2023. Java in a Nutshell. " O'Reilly Media, Inc.".
- Mekterović, I., Brkić, L., Milašinović, B. and Baranović, M., 2020. Building a comprehensive automated programming assessment system. IEEE access, 8, pp.81154-81172.
- Muqorobin, M. and Rais, N.A.R., 2022. Comparison of PHP programming language with codeigniter framework in project CRUD. International Journal of Computer and Information System (IJCIS), 3(3), pp.94-98.
- Kanika, Chakraverty, S. and Chakraborty, P., 2020. Tools and techniques for teaching computer programming: A review. Journal of Educational Technology Systems, 49(2), pp.170-198.
- Kato, J. and Igarashi, T., 2020. VisionSketch: integrated support for example-centric programming of image processing applications. In Graphics Interface 2014 (pp. 115-122). AK Peters/CRC Press.
- Tupac-Yupanqui, M., Vidal-Silva, C., Pavesi-Farriol, L., Ortiz, A.S., Cardenas-Cobo, J. and Pereira, F., 2022. Exploiting Arduino features to develop programming competencies. IEEE Access, 10, pp.20602-20615.