07.06.2022

I need help with these, sorry to bother

. 4

Faq

Computers and Technology
Step-by-step answer
P Answered by Specialist

A C++ program was used for a user or the computer play a guessing game.

Explanation:

The C++ code to this question:

#include <iostream>

#include <cstdlib> // srand and rand functions

#include <ctime> // time function

using namespace std;

int main()

{

const int C = 100;// constant integer with defined value 100

char type;// type of option chosen

cout<<"Would you like to (p)lay or watch the (c)omputer play?"<<endl;

cin>>type;// input of type

do{// for first iteration you can't choose q

int x;

srand(unsigned(time(NULL))); // set different seeds to make sure each run of this program will generate different random numbers

x = ( rand() % C);

x++;// random value between 1 and 100

int check=-1;// make initial check=-1

int ends=C;// for type selected as c, make the initial guess to be chosen from 1 to 100

int start=1;

while(1)

{

if(type=='p')// if selected type is p

{

cout<<"Enter your guess in between 1 and 100."<<endl;

cin>>check;

}

else if(type=='c')// if selected type is c

{

check=start+(rand()%(ends-(start-1)));//get a random number between updated start and ends for computer guessing

cout<<"The computer's guess is "<<(check)<<"."<<endl;

}

else// if type is not equal to c or p or q

{

cout<<"Invalid option chosen"<<endl;

break;

}  

if(check>x)// if the guess is greater

{

cout<<"Sorry, your guess is too high, try again."<<endl;

ends=check-1;// update ends in case type is c

}

else if(check<x)

{

cout<<"Sorry, your guess is too low, try again."<<endl;

start=check+1;// update start

}

else// if right number is selected

{

cout<<"Congrats, you guessed the correct number, "<<x<<"."<<endl;

break;

}

}

cout<<"Would you like to (p)lay or watch the (c)omputer play or (q)uit?"<<endl;

cin>>type;

}while(type!='q');

return 0;

}

Note: Kindly find an attached copy of the screenshot of execution of code below


In this warm up project, you are asked to write a C++ program proj1.cpp that lets the user or the co
Computers and Technology
Step-by-step answer
P Answered by Specialist

A C++ program was used for a user or the computer play a guessing game.

Explanation:

The C++ code to this question:

#include <iostream>

#include <cstdlib> // srand and rand functions

#include <ctime> // time function

using namespace std;

int main()

{

const int C = 100;// constant integer with defined value 100

char type;// type of option chosen

cout<<"Would you like to (p)lay or watch the (c)omputer play?"<<endl;

cin>>type;// input of type

do{// for first iteration you can't choose q

int x;

srand(unsigned(time(NULL))); // set different seeds to make sure each run of this program will generate different random numbers

x = ( rand() % C);

x++;// random value between 1 and 100

int check=-1;// make initial check=-1

int ends=C;// for type selected as c, make the initial guess to be chosen from 1 to 100

int start=1;

while(1)

{

if(type=='p')// if selected type is p

{

cout<<"Enter your guess in between 1 and 100."<<endl;

cin>>check;

}

else if(type=='c')// if selected type is c

{

check=start+(rand()%(ends-(start-1)));//get a random number between updated start and ends for computer guessing

cout<<"The computer's guess is "<<(check)<<"."<<endl;

}

else// if type is not equal to c or p or q

{

cout<<"Invalid option chosen"<<endl;

break;

}  

if(check>x)// if the guess is greater

{

cout<<"Sorry, your guess is too high, try again."<<endl;

ends=check-1;// update ends in case type is c

}

else if(check<x)

{

cout<<"Sorry, your guess is too low, try again."<<endl;

start=check+1;// update start

}

else// if right number is selected

{

cout<<"Congrats, you guessed the correct number, "<<x<<"."<<endl;

break;

}

}

cout<<"Would you like to (p)lay or watch the (c)omputer play or (q)uit?"<<endl;

cin>>type;

}while(type!='q');

return 0;

}

Note: Kindly find an attached copy of the screenshot of execution of code below


In this warm up project, you are asked to write a C++ program proj1.cpp that lets the user or the co
English
Step-by-step answer
P Answered by Master
1. She was sorry that she didn't listen to her mother's advice.
She wished she listened to her mother's advice. 
2. They regretted that their child got involved in that matter.
They wished they didn't get their child involved in that matter.
3. I regret that I don't have enough money to go to Paris.
I wish I had enough money to go to Paris.
4. She regrets she hadn't taken TOEFL with us.
She wishes she took TOEFL with us.
5. We are sorry she doesn't know about their engagement.
We wish she knew about their engagement.6. Is he sorry for the time spent on trifles?
Is he wishing he didn't spend time on trifles?7. I am sorry she doesn't want to apply for this scholarship.I wish she wanted to apply for this scholarship.8. Doesn't she regret that she did not manage to cope with the task?
Isn't she wishing she managed to cope with the task?9. What a pity that she didn't suggest this when we met.
I wish she suggested this when we met.10. It's a pity there are no fresh vegetables in winter.
I wish there were fresh vegetables in winter.11. I regret I haven't read "Pride and Prejudice" by Jane Austen.
I wish I read "Pride and Prejudice" by Jane Austen.12. She is so sorry she was not suggested to join one of the public services.She wishes she was suggested to join one of the public services.
13. She regrets she avoided the walk to the village.
She wishes she didn't avoid the walk to the village.
14. It's a pity she is not well settled.
I wish she was well settled.15. He was sorry her collection was not larger.
He wished her collection was larger.16. I am sorry I can't take this as a compliment.I wish I could take this as a compliment.
17. It is a pity you have to go.I wish you didn't have to go.
18. He regretted she left for Cambridge.He wished she didn't leave for Cambridge.
Hello!   paraphrase the following using the verb 'wish' followed by an object clause in the subjunct
Hello!   paraphrase the following using the verb 'wish' followed by an object clause in the subjunct
English
Step-by-step answer
P Answered by Specialist
1. She was sorry that she didn't listen to her mother's advice.
She wished she listened to her mother's advice. 
2. They regretted that their child got involved in that matter.
They wished they didn't get their child involved in that matter.
3. I regret that I don't have enough money to go to Paris.
I wish I had enough money to go to Paris.
4. She regrets she hadn't taken TOEFL with us.
She wishes she took TOEFL with us.
5. We are sorry she doesn't know about their engagement.
We wish she knew about their engagement.6. Is he sorry for the time spent on trifles?
Is he wishing he didn't spend time on trifles?7. I am sorry she doesn't want to apply for this scholarship.I wish she wanted to apply for this scholarship.8. Doesn't she regret that she did not manage to cope with the task?
Isn't she wishing she managed to cope with the task?9. What a pity that she didn't suggest this when we met.
I wish she suggested this when we met.10. It's a pity there are no fresh vegetables in winter.
I wish there were fresh vegetables in winter.11. I regret I haven't read "Pride and Prejudice" by Jane Austen.
I wish I read "Pride and Prejudice" by Jane Austen.12. She is so sorry she was not suggested to join one of the public services.She wishes she was suggested to join one of the public services.
13. She regrets she avoided the walk to the village.
She wishes she didn't avoid the walk to the village.
14. It's a pity she is not well settled.
I wish she was well settled.15. He was sorry her collection was not larger.
He wished her collection was larger.16. I am sorry I can't take this as a compliment.I wish I could take this as a compliment.
17. It is a pity you have to go.I wish you didn't have to go.
18. He regretted she left for Cambridge.He wished she didn't leave for Cambridge.
Hello!   paraphrase the following using the verb 'wish' followed by an object clause in the subjunct
Hello!   paraphrase the following using the verb 'wish' followed by an object clause in the subjunct
English
Step-by-step answer
P Answered by Specialist

\tiny\texttt{ • Don't Spam }

Try asking the Studen AI a question.

It will provide an instant answer!

FREE