adding switches

is there a way for me to add swtiches?
if i can't what are my other options can you give me an example?

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
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int A,B,C;
    double total;
    int cash,product;
    double change;
    
    switch (product){
    case 1:
    printf("how many product A: \n");
    cin>>A;
    break;
    
    case 2:
    printf("how many product B: \n");
    cin>>B;
    break;
    
    case 3:
    printf("how many product C: \n");
    cin>>C;
    break;
    }
    
    total=(case 1*10)+(case 2*20)+(case 3*30);
    \\ unit price of product A is 10
    printf("total amout due is: %lf  \n", total);




Another problem of mine is that i cant add answer with another answer


1
2
3
4
5
6
7
8
9
printf("enter amount paid by customer: \n");
    cin>>cash;
    
    
    do{
    change=total-cash;
    printf("total change will be:    \n", change);
    }
    while(total>=cash);





closed account (Lv0f92yv)
I'm not entirely sure what you're trying to do. What do you mean by 'add switches'? You can add the values in the variables used in the switches, is that what you mean?

The printf() function is a C function. For c++, you would use something like: cout << "Total change will be: " << change;
Topic archived. No new replies allowed.