### Negative number check

The code on lines 44-53 is suppose to display a message when the user enter a negative number, however, when a correct positive number is entered the message is display again.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155`` ``````#include #include using namespace std; int main() { char carType; int A, B, C; char keepgoing; char condition; double miles, per_miles,upgrade; double days, per_days,new_char; double price, fees, charges,discount, new_charges; do { do { cout<<"Which car are you shopping for? (enter A, B, C)?"<>carType; }while (carType != 'A' && carType != 'B' && carType != 'C' ); cout<<"What condition? (S, O, or, P)"<>condition; if ((condition !='S') || (condition !='O') || (condition !='P')); else cout<<"Please enter the correct response"<>miles; do { cout<<"How many days?"<>days; cout<<"You enter a negative number,please try again."<>keepgoing; }while (keepgoing == 'Y' || keepgoing == 'y'); cout<<"Thank you for using this program. Goodbye."<
You don't actually check the sign of the number in the 44-53 fragment.
Try to reproduce your problem with a simpler program
 ``1234567891011121314`` ``````#include using namespace std; int main(){ double days; //¿double? do { cout<<"How many days?"<>days; cout<<"You enter a negative number,please try again."<
Also note, indentation.

If you follow that snip you should realize that you print the message of `negative number' before checking it.
Topic archived. No new replies allowed.