Answer to Question #287373 in C++ for Nica

Question #287373

Each frame except for the tenth consists of one or




two balls, or attempts to knock down the ten pins at the end of the alley. Doing so on the




first ball of the frame is called a strike, and the second ball of the frame is not rolled.




Knocking down all ten pins with both balls (having left some up with the first ball) is called a




spare. If both attempts to knock down the pins leave some standing, the frame is called an




open frame. A spare in the tenth frame gives the bowler one extra ball; a strike in the tenth




gives him or her two extra balls. A bowling score is computed as follows. A strike counts as




10 points plus the sum of the next two balls. A spare counts as 10 points plus the next ball.




Suppose for example that the sequence of balls was




9 1 10 10 10 6 2 7 3 8 2 10 9 0 9 1 1 0




The score for the ten frames would be




Frame score




----- ----- 1 10




2 30




3 56




4 74




5 82




6 100




7 120




8 139




9 148




10 168

1
Expert's answer
2022-01-20T01:46:42-0500
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;


int main()
{
    int num, guess, bow = 0;
    srand(time(0)); 
    num = rand() % 100 + 1; 
    cout << "Bowling Game\n\n";


    do
    {
        cin >> guess;
        bow++;


        if (guess > num)
            cout << "Too high!\n\n";
        else if (guess < num)
            cout << "Too low!\n\n";
        else
            cout << "\nCorrect! You got it in " << bow << " guesses!\n";
    } while (guess != num);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment