|
From: Shawn <tre...@gm...> - 2008-02-11 23:10:12
|
This is the first time that I'm trying to use C's build in data type for
true/false and I'm having some problems.
Basically, I'm trying to use bool to keep the program from displaying
results if invalid data is entered.
if (weight <= 0 || weight > 20000)
cout<<"Please enter either a positive number or a weight of 20
kilograms or less for your package.\t\t";
if (distance < 10 || distance > 3000)
cout<<"We don't ship to distances of less then 10 miles or more then
3000 miles.\t\t";
If this is the case and they do enter invalid data, I want bool to stop
the output of the program from printing on screen, I just want the
program to tell the user that they need to enter the right information
as prompted above.
cout<<"The total shipping charges for your package is
$"<<setprecision(2)<<shippingCharges<<endl;
What's the best way to go about this? I was thinking of declaring bool
output = True in the beginning of the program and then right after those
two input validation statements set output = false, but then what would
I put just before the total shipping charges line so it wouldn't print?
Also, I'm having problems setting output = false, it says false is
undeclared. I thought bool was a built in true/false data type?
thx
|