### sales and total

Hello I am new to c++ and I am trying to run a simple sales program. All the program has to do is run a program that reads the series of pairs of numbers as follows:
A. product number
B. Quantity sold for one day

The program must have the switch statement to help determine the retail price for each product and program should calculate and display the total retail value of all products sold last week.
I have the code completely done but the program wont recognized the following characters. count, cin, and end1. Here is the code.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869`` ``````#include int main() { int ProductNumber; double QuantitySold; double Calculate; double sum1= 2.98, sum2= 4.50, sum3= 9.98, sum4= 4.49, sum5= 6.87; count<<"Enter the product number (1-5) (0 to Stop): "; cin>>ProductNumber; count<<"Enter quantity sold: "; cin>>QuantitySold; while (ProductNumber != 0 ){ switch (ProductNumber) { case 1: sum1+=(2.98*QuantitySold*Calculate); count<<"The sales for this Product 1 is \$ "<>ProductNumber; count<<"Enter quantity sold: "; cin>>QuantitySold; } count<<"Total Sales for the week"<

I really would appreciated the help.
First, there is no such thing as count. It is cout

Second you forgot to include using namespace std.

So you have to change your count to cout and at the top of your code before main, write "using namespace std;" without the quotation
You could use `using namespace std;` but that would pull in the entire std namespace. This is not generally considered good practice - it could lead to name clashes.

Much better is to selectively choose the members of std that you want to use:

 ``123`` ``````using std::cout; using std::cin; using std::endl;``````

Or you can simply make sure you properly qualify the namespaces when you use the symbols, e.g.

 ``1234`` `````` std::cout << "Enter the product number (1-5) (0 to Stop): "; std::cin >> ProductNumber; std::cout << "Enter quantity sold: "; std::cin >> QuantitySold;``````
okay I did that and it worked, but now every time I when I enter the number of items sold it just gives me the same amount the item cost and when I do the switch the program it just loops forever.
Last edited on
Post new code here
Topic archived. No new replies allowed.