How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask LogicPro Your Own Question

LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 9476
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
29751445
Type Your Homework Question Here...
LogicPro is online now
A new question is answered every 9 seconds

In this exercise, youll re-create the classic race of the

Resolved Question:

In this exercise, you’ll re-create the classic race of the tortoise and the hare. You’ll use random number generation to develop a simulation of this memorable event.
Our contenders begin the race at “square 1” of 70 squares. Each square represents a possible position along the race course. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground.
There is a clock that ticks once per second. With each tick of the clock, your program should use function moveTortoise and moveHare to adjust the position of the animals according to the rules in Fig. 8.18. These functions should use pointer-based pass-by-reference to modify the position of the tortoise and the hare.
Use variables to keep track of the positions of the animals (i.e., position numbers are 1–70). Start each animal at position 1 (i.e., the “starting gate”). If an animal slips left before square 1, move the animal back to square 1.
Generate the percentages in the preceding table by producing a random integer i in the range 1 ≤i ≤10. For the tortoise, perform a “fast plod” when 1 ≤ i ≤5, a “slip” when 6 ≤ i ≤7 or a “slow plod” when 8 ≤ i ≤10. Use a similar technique to move the hare.
Begin the race by displaying
BANG !!!!!
AND THEY'RE OFF !!!!!

For each tick of the clock (i.e., each repetition of a loop), display a 70-position line showing the letter T in the tortoise’s position and the letter H in the hare’s position. Occasionally, the contenders land on the same square. In this case, the tortoise bites the hare and your program should display OUCH!!! beginning at that position. All positions other than the T, the H or the OUCH!!! (in case of a tie) should be blank.
After displaying each line, test whether either animal has reached or passed square 70. If so, display the winner and terminate the simulation. If the tortoise wins, display TORTOISE WINS!!! YAY!!! If the hare wins, display Hare wins. Yuch. If both animals win on the same clock tick, you may want to favor the tortoise (the “underdog”), or you may want to display It's a tie. If neither animal wins, perform the loop again to simulate the next tick of the clock.
Submitted: 9 months ago.
Category: Homework
Expert:  LogicPro replied 9 months ago.
Hi,
Welcome here.
My name is XXXXX XXXXX I will help you.
What is the deadline?
Which C++ compiler you are using?
Customer: replied 9 months ago.

Do you need any other information?

Expert:  LogicPro replied 9 months ago.
Yes.
What is the deadline?
Which C++ compiler you are using?
Customer: replied 9 months ago.

Deadline: 11/05 @ 11:55


mingw


netbean ide

Expert:  LogicPro replied 9 months ago.
ok.

Please bookmark this page / add to favorites to come back later on

Expert:  LogicPro replied 9 months ago.
Download answer from here: Tortoise_Hare_Race_Simulation_CPP.cpp

You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers.

It will ensure that question is for me.

Please bookmark my profile page:

http://www.justanswer.com/homework/expert-logicpro/

so you can come back and ask me a question anytime.

Remember, if for any reason you are unsatisfied with my answer, we can continue the conversation until you’re satisfied and rate my answer as excellent. I can address follow up questions on original requirements at no extra charge and I’m always here to help.

Thank you for using this site!

Customer: replied 9 months ago.

hi! that's great but, i dont wannna print any dots and when generating a random number we should use random engine that comes with C++ 11

Expert:  LogicPro replied 9 months ago.
What do you want to print instead of dots?
Also I used rand() which is C++ function? If there is something else 'random engine that comes with C++ 11', please provide example
Customer: replied 9 months ago.

2 // Using a C++11 random-number generation engine and distribution
3 // to roll a six-sided die.
4 #include <iostream>
5 #include <iomanip>
6 #include <random> // contains C++11 random number generation features
7 #include <ctime>
8 using namespace std;
9
10 int main()
11 {
12 // use the default random-number generation engine to
13 // produce uniformly distributed pseudorandom int values from 1 to 6
14 default_random_engine engine(static_cast<unsigned int>( time(0) ) );
15 uniform_int_distribution<unsigned int> randomInt( 1, 6 );
16
17 // loop 10 times
18 for ( unsigned int counter = 1; counter <= 10; ++counter )
19 {
20 // pick random number from 1 to 6 and output it
21 cout << setw( 10 ) << randomInt( engine );
22
23 // if counter is divisible by 5, start a new line of output
24 if ( counter % 5 == 0 )
25 cout << endl;
26 } // end for
27 } // end main


 


instead of dot just blank is ok

Expert:  LogicPro replied 9 months ago.

Download again from here: Tortoise_Hare_Race_Simulation_CPP.cpp

Customer: replied 9 months ago.

The output shows most of the time the tortoise is not moving.

Customer: replied 9 months ago.

BANG!!!!!


AND THEY'RE OFF!!!!!


T


T


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T


T H


T H


T


T


T


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H


T H



here the hare is first but it says tortoise wins

Expert:  LogicPro replied 9 months ago.
Could you provide complete requirements in a word document?
Customer: replied 9 months ago.

Now, the program looks fine. Can you simply the body of moveHare, and moveTortoise. We haven't learned : ? Can you do without using these?

Expert:  LogicPro replied 9 months ago.
Download:
http://www.wikisend.com/download/176662/Tortoise_Hare_Race_Simulation_CPP.cpp

Tortoise will not move if postion is < 2
Customer: replied 9 months ago.

can you send the link to answer again I can't click here

Expert:  LogicPro replied 9 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
LogicPro, Engineer
Category: Homework
Satisfied Customers: 9476
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
LogicPro and 8 other Homework Specialists are ready to help you

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience