Programming Problem.

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.
Er... why should we solve your homework for you? O_o
http://cplusplus.com/articles/DjGEy60M/

-Albatross
closed account (z05DSL3A)
I don't like that one, have you got another?
i don't have idea to solve it.Can you give hint ?
Well...

If you're having trouble understanding functions:
http://cplusplus.com/doc/tutorial/functions/
http://www.cprogramming.com/tutorial/lesson4.html

If you're having trouble with flowcharts:
http://www.mindtools.com/pages/article/newTMC_97.htm
http://xkcd.com/518/ (Something amusing for after you solve the problem. n_n)

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. :)

-Albatross
Last edited on
‎#include<iostream>
using namespace std;

float input_product_price(float product_price);
void display_total_price(float total_price);

void main()
{
float product_price;
float total_price;
int quantity;

total_price=(product_price*quantity)/2;

}
float product_price()
{
float productofprice;
cout<<"enter the product price:";
cin>>productofprice;
return productofprice;
}
void display_total_price(float total_price)
{
cout<<"your total price for this purchased is = "<<total_price;
}


where i get an error?
Topic archived. No new replies allowed.