- In Short In This Project You Are Asked To Create A Program To Simulate A General Goods Store Your Store Should Include 1 (42.94 KiB) Viewed 36 times
In short In this project, you are asked to create a program to simulate a General Goods Store. Your store should include
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
In short In this project, you are asked to create a program to simulate a General Goods Store. Your store should include
In short In this project, you are asked to create a program to simulate a General Goods Store. Your store should include three arrays of size 5: the first should include the names of your goods you can set these, the second the price of each good (you may also set these), and finally the third should contain the car stock of each good (randomly determined). All three arrays should correspond to each other based on index inde 0 in names corresponds to index 0 in prices and indes in stock). Alliwa user to purchase goods as long as item is in stock and the user till has money. In more detail Create a Store class with four attributes, a decimal for the shop earnings, a string array of prod ut names, a decimal array of product prices, and an int array of product stock. The first two at may be completely set by the programmer, but the third should be randomly decided at instantiation. Your constructor should call the method Stock to randomly set the stock of each item to a value between 0 and 10, both incive The Stock method should iterate through the array, setting a random value between 0 and 10 for each item. It need not take any arguments nor return any value . Include a purchase method with two arguments, a string itemName and decimal fund Name matches an item in your name array, increase your earnings based on the tem price and decrease the stock by one. If there is no match for itemName, the user does not have enough funds, or if it is out of stock, have the method return-1, else return the user'sated funds . Include a ToString method to display all items with their corresponding prices and stock In the Main method Project • Instantiate a Store object. Ask the user for his or her starting funds. If the valor is not a number or is less than 0. keep asking you get a sensible value Display the current state of your shop with ToString Ask the user what he or she wishes to purchase. Call the Purchase method. If Purchase returns -1, tell the user that the selection was invalid, ele set the user's budget to the returned valu Ask the user if that will be all after each item, quining if the user says "Yes" or "Twith any captation Example Here is a sample execution Welcome to my General Goods Store. What is your current budget? Pocket Lint CSC11301 This is nonsessical, what is your current budget? -S This is sonsessical, what is your current budget? 200 Great! Your budget is $200.00. Our current stock in: Water $1.00 Candy 10.25 3 Pencil $0.10 0 Book $9.99 1 32" LED Television $299.976 What would you like to purchase? Nothing I'm sorry, but that was an invalid selection. Would you like to make another purchase? Enter "Yes" or "Y" to continue. yest What would you like to purchase? Pencil I'm sorry, but that was an invalid selection. Would you like to make another purchase? Enter "Yes" or "1" to continue. What would you like to purchase? Vater Thanks for the purchase! Your budget is now $199.00. Our current stock is: Vater $1.00 7 Candy 10.25 3 Pencil $0.100 Book $9.99 1 32" LED Television $299.97 6 Would you like to make another purchase? Enter "Yes" or "y" to continue. 50+ Thanks for your business! Please come again!