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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<iostream>

 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 $ "<<sum1<<endl;
       break;
 
       case 2:
       sum2=(4.50*QuantitySold*Calculate);
       count<<"The sales for this Product 2 is $ "<<sum2<<endl;
       break;
 
       case 3:
       sum3+=(9.98*QuantitySold*Calculate);
       count<<"The sales for this Product 3 is $ "<<sum3<<endl;
       break;
 
       case 4:
       sum4+=(4.49*QuantitySold*Calculate);
       count<<"The sales for this Product 4 is $ "<<sum4<<endl;
       break;
 
       case 5:
       sum5+=(6.87*QuantitySold*Calculate);
       count<<"The sales for this Product 5 is $ "<<sum5<<endl;
       break;
 
       default:
       count << "Invalid product code: " << ProductNumber
       << "\n Quantity: " << QuantitySold << '\n';
       break;
  
 
}
 
 count<<"\nEnter the product number (1-5) (0 to Stop): ";
 cin>>ProductNumber;
 count<<"Enter quantity sold: ";
 cin>>QuantitySold;
}
 
 count<<"Total Sales for the week"<<endl;
 count<<"Product 1 $ "<<sum1<<endl;
 count<<"Product 2 $ "<<+sum2<<endl;
 count<<"Product 3 $ "<<sum3<<endl;
 count<<"Product 4 $ "<<sum4<<endl;
 count<<"Product 5 $ "<<sum5<<endl;

 


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:

1
2
3
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.

1
2
3
4
       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.