help with c++ lab please
Go to solution
Solved by Cruiseshipfan,
Ok I know your issue.
do{ cout << "\nWhat is the cost of the book? $"; cin >> Cost; }while(Cost<0); cout <<"Invalid entry must be greater than 0. ";
You are looping while the value is correct. You should have it loop while it is incorrect and have the error statement in an if. So when ever the input value is correct you are causing it to go back to the top of the loop, but when you input the incorrect value it is leaving the loop. So reverse the conditions and add an if.
As for it starting on the same line. You need to tell it to go to the next line in the error message.
For example
do{ //GET INFORMATION if (cost < 2) { cout << "Value is too small\n"; }} while(cost < 2)

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now