If statement

I want to get the total price of foods that i have entered ,Here i'm getting a incorrect total price .
Can anyone show me how to fix it.?
Thanks..

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
 #include<iostream>
#include<cstring>
using namespace std ;
int main()
{

string fi;
int ni;
double x;
double sum =0;
char exit ;
do
{

cout<<"Enter the Food item :";
cin>>fi;

        if((fi!="AK012")&&(fi!="AK013")&&(fi!="AK014")&&(fi!="AK015"))
        {
          cout<<"Invalis food item "<<endl;
          break;
        }
cout<<"Enter the number of items needed:";
cin>>ni;



        if(fi=="AK012")
   {
       x=(120-(120/0.02))*ni;

    }

                if(fi=="AK013")
   {
       x=(350-(350/0.03))*ni;

    }

        if(fi=="AK014")
   {
       x=(350-(350/0.03))*ni;

    }

                if(fi=="AK015")
   {
       x=(250-(250/0.05))*ni;

    }
sum=sum +x;
cout<<"Do you have more data..?:";
cin>>exit;
//sum =sum+x ;
        if((exit=='n')||(exit=='N'))
        {
        cout<<"Toal price is:"<<sum<<endl;
        break;
        }

}
                while((exit=='y')||(exit=='Y'));

return 0;
}

x=(120-(120/0.02))*ni; What the purpose of this line? What are you doing here. What is 120 and 0.02?
Price and discount
120/0.02 Why are you dividing here?
120 / 0.02 =6000. You should multiply instead.
Mistake..Thanks..
Topic archived. No new replies allowed.