Heya guys new to this great board and programming in general (well I did a little plain english if you can consider that a programming language). I'm also back in college as a freshman at 26 so I think I am having a bit more of a problem getting the swing of it then my younger counterparts because I didn't have this stuff in high school. But I regress...
I am trying to create a mail/weight/cost calculator for introo to c++
I guess its a problem more or less with if...else statements. Heres my code:
Code:#include <iostream> using namespace std; const double ENVELOPE_POSTAGE = 1; const double ADD_TO_FIRST_CLASS = 0.23; const double FIRST_PRIORITY_COST = 3.85; const double SECOND_PRIORITY_COST = 8.40; const int LOW_RANGE = 1; const int FIRST_CLASS_MAX = 13; const int FIRST_PRIORITY_MAX = 159; const int PRIORITY_MAX = 160; int main () { int weight; double cost; int mailService; cout<<"What is the weight of the envelope that you would like to send? "<<endl; cin>>weight; if (weight > PRIORITY_MAX) cout<<"You have entered an invalid number"<<endl; //return 0; if(weight < LOW_RANGE) cout<<"Your postage is in the low range and it's envelope postage"; //return 0; if(weight <= FIRST_CLASS_MAX) cout<< cout<<"First Class Mail"<<endl; cost = .37 + (weight - 1) * .23; cout<<"You owe "<<cost<<endl; cout<<endl; return 0; if(weight = 160) cout<<"Priority mail"<<endl; cost = 8.40; cout<<"you owe 8.40"<<endl; return 0; //cout<<"Your postage is "; //cout<<ADD_TO_FIRST_CLASS<<" and it's First Class"; //cout<<endl; //if(weight <= FIRST_PRIORITY_MAX) //cout<<"your postage is "; //cout<<FIRST_PRIORITY_COST<<" and it's Priority"; //cout<<endl;
the problem is when I try to get it to calculate a statement it also calculate the others....and I don't want that. Anyone take a stab at what I am doing wrong?