subject

Must be python format Create a program which will choose a random number between 1 and 1000.
Ask the user to guess at the number, and give the user feedback if their guess is too high or too low.
Also, keep track of the number of guesses that the user makes.
"Redirect" the user if they enter a number outside of the range of 1 to 1000, and the error should not count as one of their guesses.
When the user finally guesses the answer, congratulate them and inform them how many guesses it took them to arrive at the correct number. (and the program should end)
Much of this will be done using the WHILE command, and perhaps an IF statement.

(sample output of the program is below)

Guess a number between 1 and 1000? 500
Your guess is too low! Try a higher number.

Guess a number between 1 and 1000? 2000

Whoops, guess a number between 1 and 1000? 750
Your guess is too high! Try a lower number.

Guess a number between 1 and 1000? 625
Your guess is too high! Try a lower number.

Guess a number between 1 and 1000? 560
Your guess is too high! Try a lower number.

Guess a number between 1 and 1000? 530
Your guess is too high! Try a lower number.

Guess a number between 1 and 1000? 515
Your guess is too low! Try a higher number.

Guess a number between 1 and 1000? 520

Your guess is too high! Try a lower number.

Guess a number between 1 and 1000? 517

Your guess is too low! Try a higher number.

Guess a number between 1 and 1000? 518

You got it! The number is 518 and you got it in 9 guesses!

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, jhit
Matlab question: use switch and anythe lottery game matches three different integer numbers between 1 and 10. winning depends on how many matching numbers are provided by a player. the player provides three different integers between 1 and 10.if there is a match of all 3 numbers, the winning $ 1000.if there is a match with 2 numbers, the winning $ 10.if there is a match of all with 1 numbers, the winning $ 1.with no match, the winning is $0.write a function lottery3 that checks three numbers provided by a player and determine the winning amount. if the user mistakenly enters same number twice/thrice and if that number matches one of the winning numbers, the code should count that number only once and display correct result. the player doesn’t have to guess the order of numbers. the input to the function lottery3 can have up to two input arguments. the first input argument is a row array numbers with 3 numbers. if the second argument input testcode is present, and is a row vector of 3 values, the function lottery3 uses the code in testcode as the three winning numbers (the test must be three different integer numbers between 1 and 10), else three different numbers will be automatically generated by testcode. the ouput should return the variable winnings and the three winning numbers in the row array winnumbers. hint: make use of the internal function any. restriction: the function must use switch-case statements to determine the winning. example #1: winning = lottery3( [1,2,1],[1,2,3])produceswinning =10example #2: [winning, winnumbers] = lottery3( [1,2,3])produceswinning =3winnumbers =8 5 3
Answers: 1
image
Computers and Technology, 22.06.2019 19:00, dadonelson2109
If your accelerator suddenly gets stuck what should you do
Answers: 2
image
Computers and Technology, 23.06.2019 02:50, CrusaderLord
Define a class named movie. include private fields for the title, year, and name of the director. include three public functions withprototypes void movie: : settitle(cstring); , voidmovie: : setyear(int); , void movie: : setdirector(string); . includeanother function that displays all the information about a movie. write a main() function that declares a movie object namedmyfavoritemovie. set and display the object's fields. this is what i have but know its wrong since it will notcompile: #include#includeusing namespace std; //class declarationclass movie{private: string movietitle ; string movieyear; string directorname; public: void settitle(string title); void setyear(string year); void setdirector(string director); void displayinfo(); }; //class implementationvoid movie: : settitle(string title){ movietitle = title; cout< < "what is the title of themovie? "< > temp; myfavoritemovie. settitle(temp); cout< < "enter movie year"< > temp; myfavoritemovie. setyear(temp); cout< < "enter director'sname"< > temp; myfavoritemovie. setdirector(temp); //display all the data myfavoritemovie. displayinfo(); system("pause"); return 0; this code is not entirely mine someone on cramster edited my firstcode but then i try manipulating the new code and i still get acompile error message : \documents\visual studio 2008\projects\movie\movie\movie. cpp(46) : error c2679: binary '< < ' : no operator found which takes aright-hand operand of type 'std: : string' (or there is no acceptableconversion)c: \program files (x86)\microsoft visual studio9.0\vc\include\ostream(653): could be'std: : basic_ostream< _elem,_traits> & std: : operator< < > (std: : basic_ostream< _elem,_traits> & ,const char *)w
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, devnnn44
What is the original authority for copyright laws
Answers: 1
You know the right answer?
Must be python format Create a program which will choose a random number between 1 and 1000.
...

Questions in other subjects:

Konu
Biology, 08.12.2019 12:31