This code represents a simple computer shop program that allows...
This code represents a simple computer shop program that allows customers to select products and calculate the total amount of their purchase.
The program starts by initializing arrays for the maximum stock, prices, and descriptions of the products.
In the main method, the program enters a loop that asks the user if there is a new customer. If the user enters 'y', the program calls the processProductSelection method to handle the product selection process. If the user enters 'n', a message is displayed and the program ends. If the user enters any other input, an error message is displayed. If the user cancels the input dialog, a thank you message is displayed and the program ends.
The processProductSelection method handles the product selection process. It displays a list of available products and their prices. The user can select a product by entering the corresponding product code. If the user enters '0', the process ends. If the user enters an invalid product code or a product that is out of stock, an error message is displayed. The user is then prompted to enter the quantity of the selected product. If the quantity is greater than the available stock, an error message is displayed. If the input is valid, the program calculates the total amount for the selected product, updates the stock, and adds the product to the receipt.
After the product selection process ends, the receipt and the total amount are displayed in a message dialog.
The showThankYouMessage method displays a thank you message along with the total amount.