The code on lines 44-53 is suppose to check see if the user enter a negative and produce a message, however, when the use enters a positive code produces the display again.

#include<iostream>
#include<cctype>
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)?"<<endl;
    cin>>carType;

    }while (carType != 'A' && carType != 'B' && carType != 'C' );



    cout<<"What condition? (S, O, or, P)"<<endl;
    cin>>condition;

    if ((condition !='S') || (condition !='O') || (condition !='P'));


    else
      cout<<"Please enter the correct response"<<endl;



    cout<<"How many miles?"<<endl;
    cin>>miles;

 do 
  {

  cout<<"How many days?"<<endl;
  cin>>days;

  cout<<"You enter a negative number,please try again."<<endl;


 }while (days < 0);

         cout.setf(ios::fixed);
         cout.setf(ios::showpoint);
         cout.precision(2);



         switch(carType)
      {

         case 'A':

         per_miles = miles * 0.10;
         per_days = days * 29.95;
         price = per_miles + per_days;


         break;

         case 'B':

         per_miles = miles * 0.15;
         per_days = days * 35.95;
         price = per_miles + per_days;



         break;

         case 'C':

          per_miles = miles * 0.20;
         per_days = days * 39.95;
         price = per_miles + per_days;



         break;

         default:
         cout<<"You entered an incorrect car choice"<<endl;
         }

         if(condition =='O')
         {
            fees = price * 0.10;
            price = price - fees;

         cout<<"The charges are?"<<price<<endl;



         }
         else if (condition == 'P')
         {
            fees = price * 0.10;
            price = price + fees;

         cout<<"The charges are?"<<price<<endl;




         }
         else
         {
         cout<<"The charges are?"<<price<<endl;
         }


               if (condition =='S')
               {
               fees = price * 0.10;
               new_charges = price + fees;
               discount = new_charges * 0.05;
               upgrade = new_charges - discount;

               cout<<"You may upgrade for a total cost of $"<<upgrade<<endl;
              }            
             else if(condition =='O')
             {
               discount = price * 0.05;
               upgrade = price - discount;

               cout<<"You may upgrade for a total cost of $"<<upgrade<<endl;
            }
            else
            {          
           cout<<"There are upgrades avialble"<<endl;

           }


         cout<<"Do you want another one (y/n)?"<< endl;
         cin>>keepgoing;

         }while (keepgoing == 'Y' || keepgoing == 'y');

         cout<<"Thank you for using this program. Goodbye."<<endl;
         }

because in line 31 you never used an 'if';)

do 
  {
  cout<<"How many days?"<<endl;
  cin>>days;
  if (days<0) cout<<"You enter a negative number,please try again."<<endl;
 }while (days < 0);

i hope help you

This article has been dead for over six months. Start a new discussion instead.