Hello! I'm currently making an inventory manager and I'm trying to figure out a way to create a code that finds the item with the highest total inventory value (which would be equal to the quantity multiplied by the price). I put what I've done so far below. Let me know if you need more information! Thank you so much for your help!
I am afraid you have another problem; you are using parallel arrays. You would have to look for the same element in three arrays, and there is a risk that something will go wrong and you will end up with an exception, or (far worse) an incorrect calculation. The object‑oriented way to do that would be to have a Product class, with description quantity and price fields. You can calculate the total price with a method quite easily.
It might be better still to have a shop class which records quantity, so the shop maintains the quantity of onions rather than the onions doing so.
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop