A hypermarket in Melaka gives a 50% discount for each product purchased by its customers due to Hari Raya Aidilfitri and Chinese New Year celebration. Draw a flowchart to illustrate the programs flow. Write a function that calculates the new price for a product purchased by the customers. Your program should also calculate the total price of all products purchased by the customer.
If you're having trouble figuring out what to do in your function:
Your professor is asking you for a function that takes in one value, and returns one value, with a 50% reduction. How do you think you could write that?
If you're having trouble figuring out how to calculate the total:
You may want to keep a variable in main() that starts at 0 and that gets increased by the new price of the last item entered each time you enter an item.
If you're having trouble figuring out what to do in general:
Do you have a list of products and their prices?
If so:
You might need to find a way to choose which product to pick. Most beginning programmers make menus in standard C++ by giving a "key", that's to say a mapping from a number to one of several choices at each place in their menu. Finding a way to write one might be a good place to start. Make sure to leave a choice to quit the program and display the total!
If not:
Then you got an easier problem! I'm guessing your professor didn't want you to connect to the hypermarket's servers and download a comprehensive list of all the products and their prices and barcodes. Instead, I'm guessing you could just get away with asking the user for prices and quitting when the user enters a negative number. Note that prices are usually decimals. :)