Create a class whose main method creates three arrays. The first array will contain five kinds of flowers – petunia, pansy, rose, violet, and carnation. The second array will contain the cost of each flower, respectively, 50 cents, 75 cents, $1.50, 50 cents, and 80 cents per flower. The third array will contain the number of flowers in stock of 5, 0, 10, 3 and 15. The main() method will call the readInput() method which will request that the user enter the desired flower. If the flower is not within the first array and message will appear and the program will end. If the flower is in a array, the user will be prompted to enter the number of flowers. If the user enters a number less than one, they will be requested to reenter the number of flowers until they enter a number greater than zero. After all requirements are met for the input, the readInput() method will call the checkStock() method. This method will check to see if the number of flowers entered was in stock. A message will display if there are enough in stock. Once the sale is complete the type of flower, number of flowers, and the total cost will display.

In order to solve this problem, we need to create a class with a main method that creates three arrays. The first array will contain the names of five different kinds of flowers – petunia, pansy, rose, violet, and carnation. The second array will contain the cost of each flower, respectively – 50 cents, 75 cents, $1.50, 50 cents, and 80 cents per flower. The third array will contain the number of flowers in stock, which are 5, 0, 10, 3, and 15.

The main method should then call the readInput() method, which will prompt the user to enter the desired flower. If the flower entered by the user is not present in the first array, a message should be displayed and the program should end. If the flower is present in the array, the user should be prompted to enter the number of flowers they want to purchase. If the user enters a number less than one, they should be requested to reenter the number of flowers until they enter a number greater than zero. Once the user provides valid input, the readInput() method should call the checkStock() method.

The checkStock() method should check if the number of flowers entered by the user is available in stock. If there are enough flowers in stock, a message should be displayed indicating that there are enough flowers available. Once the sale is complete, the type of flower, number of flowers purchased, and the total cost should be displayed.

To implement this logic, we can create a class named “FlowerShop” with a main method. In this method, we will define three arrays – one for the flower names, one for the flower costs, and one for the flower stock. We will also define variables to store the user’s input for the flower and number of flowers.

Next, we will call the readInput() method, which will prompt the user to enter the desired flower. We will use a loop to check if the entered flower is present in the first array. If it is, we will prompt the user to enter the number of flowers they want to purchase. We will continue to prompt the user until they enter a number greater than zero.

Once we have the valid input, we will call the checkStock() method, which will check if the number of flowers entered is available in stock. If it is, we will display a message indicating that there are enough flowers available. If it is not, we will display a message indicating that there are not enough flowers in stock.

Finally, we will calculate the total cost by multiplying the number of flowers with the cost of each flower and display the type of flower, the number of flowers purchased, and the total cost.

This implementation will allow the user to input a desired flower and the number of flowers they want to purchase. It will also check if the required number of flowers is available in stock and display the type of flower, the number of flowers purchased, and the total cost.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer