If I have a do-while loop like this below: and then what follows, how would I repeat the whole shabang?
and then I say thisCode:#include <iostream> # include <time.h> using namespace std ;int main() {int maximum; int minimum; int random_number; int req_subtraction; int current_total; int total; cout << "Total Limit?" << endl; //can't go over this cin >> total; cout << "Max you can add?" << endl; cin >> maximum; cout << "Minimum you can add?" << endl; cin >> minimum; cout << "Required Subtraction?" << endl; cin >> req_subtraction; srand(time(0)); //seed the random number int high=maximum; int low=minimum; do {random_number = rand () % (high - low + 1) + low;//random number between max and min cout << "Random Number is " << random_number << endl; current_total += random_number - req_subtraction; if(current_total < 0) //make so negatives equal out to zero { current_total = 0; } cout << "The current total is " << current_total << endl; } while (current_total < total); system("pause"); return 0; }
Code:cout <<"Would you like to try again? (yes/no)" << endl; cin >> yes_no; if (yes_no == "yes") { //repeat somehow? } else { cout <<"Goodbye!" <<endl; }