Program Flow

I can not seem to get this program to work. The logic may be my problem and the ranges between 0-672 will not work when the user enters a -number.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102`` ``````#include #include using namespace std; int main() { char package; double units; double fees_a, fees_b, fees_c; int A, B, C, Q; double pac_a,pac_b, pac_c; do { cout <<"Which pakage are you shopping for?:Please enter A, B, C, or Q to quit."<< endl; cin>> package; package = toupper(package); }while(package !='A' && package !='B' && package !='C' && package !='Q'); do { cout<<"How many message units?:"<>units; }while(units < 0 || units > 672); switch(package) { case 'A': if (units <=10) { fees_a = 9.95; cout<<"The charges are:"<< fees_a<< endl; } else { fees_a = (units - 10) * 2 + 9.95; cout<<"The charges are:"<< fees_a<< endl; } break; case 'B': if (units <= 20) { fees_b = 19.95; cout<<"The charges are:"<< fees_b<< endl; break; } else { fees_b = ((units - 20) + 19.95); cout<<"The charges are:"<< fees_b<< endl; } break; case 'C': fees_c = 39.95; cout<<"The charges are:"<< fees_c<< endl; break; case 'Q': cout<<"Thank you for using this program. Goodbye."<< endl; return 0; break; default: cout<<"Enter only 0 through 672."<
I don't know what you are doing, but that's what you are declaring

 ``12345`` `````` do { ... } while(units < 0 || units > 672);``````

that condition is true and keeps the do-while going only when `units` stores a value that is less than 0 or higher than 672.

basically your do-while executes at least 1 time no matter what is the value of `units` and then it checks that condition.
Topic archived. No new replies allowed.