so I'm trying to make some kind of virtual store just to test what I can do, I used the following strings: sProdus(sProduct),sPretFinal(sFinalPrice),sCantitate(sQuantity)
The problem is that I can't do math with strings, and when I change them to int variables the if statements will not work. I tried removing the " , changing the == into =.
I don't know what else I could do, could you tell me?
(When I run the following code and enter the quantity, it will always say 'Final Price' and then it shows nothing)
#include <string>
#include <iostream>
using namespace std;
int main()
{
int a=29999,b=2,c=2.5,
string sProdus; // (sProduct)
string sCantitate; // (sQuantity)
string sPretFinal; // (sFinalPrice)
sPretFinal=sProdus*sCantitate;
cout <<"Bun venit in magazinul lui Bogdan, ce doriti sa cumparati?";
cout<<endl;
cout<<endl;
cout <<"Puteti cumpara:televizor Phillips 1920x1280 (a), mere(b), banane(b)";
cout<<endl;
cout<<endl;
cout <<"Apasati litera corespunzatoare produsului pentru a vedea pretul acestuia";
cout<<endl;
cout<<endl;
cout<<"Produsul ales: ";cin>> sProdus;
if(sProdus=a){cout<<"Pretul televizorului Phillips 1920x1280: 29,999 RON";
cout<<endl;
cout<<endl;
cout<<"Cantitatea: ";cin>>sCantitate;
cout<<"Pretul final este:"<<sPretFinal;
}
if(sProdus=b){cout<<"Pretul unui mar: 2 RON";
cout<<endl;
cout<<endl;
cout<<"Cantitatea: ";cin>>sCantitate;
cout<<"Pretul final este:";sPretFinal;
}
if(sProdus=c){cout<<"Pretul unei banane:2.50 RON";
cout<<endl;
cout<<endl;
cout<<"Cantitatea: ";cin;sCantitate;
cout<<"Pretul final este:";sPretFinal;
}
if(sProdus !=c && sProdus !=a && sProdus !=b)
{
cout<<"Ne cerem scuze, dar acest produs nu exista in magazin";
cout<<endl;
}
}
I would really love if someone could help me on this :) I hope I was specific enough. :) I am using CodeBlocks btw.