So far I have tried to make a do...while loop where it asks two questions. One which is how many miles and the second which is how much does the package weigh. If the number of miles is equal to 0 or less it should output an error and then re-ask the question. Once validated it should move onto the weight question with the same requirements, and if the weight is invalid it should only repeat the weight question since the miles question is already valid.
This is the code that I have so far:
int miles = 0;
int choice = 0;
double weight = 0.0;
do
{
cout << "Enter the number of miles as a whole number: ";
cin >> miles;
if (miles > 0)
{
cout << "Enter the weight of the package in pounds: ";
cin >> weight;
if (weight > 0 && weight < 10)
{
cout << "etc etc etc";
}
else
{
cout << "\n\tError: Weight must be greater than zero and less than 10 pounds!\n" << endl;
}
}
else
{
cout << "\n\tError: Miles must be greater than zero!\n" << endl;
}
cout << "Enter 1 to continue or 0 to quit: ";
cin >> choice;
cout << endl;
}
while (choice != 0);
cout << "\nGood-bye!\n";
return 0;