D020 0 70 44 2025 3012 60432 8O 24 r 3024 sairi lked la ked for 9.1ADS E 192.143hourN 0100

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
P020
0432
24 aia
Hurester nakede
er lo
Input:
0020
10 70 44
0 025
60 432
0 100 forest
80 24 marsh
Output: Forester walked for 103.889 hours
Forester walked for 121,376 hour
Mountaineer walked for 192.143 hours
Mountaineer walked for 59.1405 hours
Unit is at 0, 100
Unit is at 0, 100
Unit is at 80, 24
Unit is at 80, 24
Input: 10 7044
604 32
80 24 mountain
Output : Forester walked for 809175 hours
Mountaineer walked for 15.1523 hours
Unit is at 80, 24
Unit is at 80, 24
Transcribed Image Text:P020 0432 24 aia Hurester nakede er lo Input: 0020 10 70 44 0 025 60 432 0 100 forest 80 24 marsh Output: Forester walked for 103.889 hours Forester walked for 121,376 hour Mountaineer walked for 192.143 hours Mountaineer walked for 59.1405 hours Unit is at 0, 100 Unit is at 0, 100 Unit is at 80, 24 Unit is at 80, 24 Input: 10 7044 604 32 80 24 mountain Output : Forester walked for 809175 hours Mountaineer walked for 15.1523 hours Unit is at 80, 24 Unit is at 80, 24
In C+,Write a program that moves a forester unit and a mountaineer unit to a given target location and
prints the number of hours it took for each unit to reach the target
First, the user will give the starting X and Y positions of the forester unit as well asa its base speed (all
Ints) Then the starting X and Y positions of the mountaineer unit as well as its base speed (all ints).
Finally, the target X and Y positions (both ints) and the terrain type (std::string).
Speed are given as distance traveled in one full day (i.e.,24 hours) and is affected by the terrain type
using a multiplier over the base speed. Also, after 1 full day, each unit rests for a certain number of
hours. Speed multiplier and rest amount of each type of unit depending on the terrain type are as
below.
Speed Matiplier
Reu Duration Alier 1day
Forester
Mouraineer
Forester
Mounmaineer
Forest
135
Moursain
14
Mansh
0.5
10
12
Qihers
0.85
011
After getting all this information, the program will move both the units to the target by printing out the
total time (in hours) it took the units to reach their target and their final positions int he format seen in
the outputs.
Requirements:
You should deline a class fort he unit, two CHILD classes of the unit class one for the forester unit, another
fort he mountaineer unit.
Coordinate information should be kept as private inside the unit class whereas the speed information
shouldbe kept as protected inside the unit class.
Classes should take the related input in their constructor functions
Lhe base unit class MUST have a public function which prints out the current location of the unit.
The base unit class MUST have a protected function which calculates the distance between itself and a
target location.
Each child classes MUST have a public function which moves the unit to a target location given the terrain
Eype, calculates the total amount of hours it took the unit to reach to the target, and print it out
Getting all the user input, instantiating objects, calling the move functions of the child classes should be
done in the main() function.
Do NOT use pollymorphisim in this question(i.e., do NOT overload the move functionof the base dass).
Transcribed Image Text:In C+,Write a program that moves a forester unit and a mountaineer unit to a given target location and prints the number of hours it took for each unit to reach the target First, the user will give the starting X and Y positions of the forester unit as well asa its base speed (all Ints) Then the starting X and Y positions of the mountaineer unit as well as its base speed (all ints). Finally, the target X and Y positions (both ints) and the terrain type (std::string). Speed are given as distance traveled in one full day (i.e.,24 hours) and is affected by the terrain type using a multiplier over the base speed. Also, after 1 full day, each unit rests for a certain number of hours. Speed multiplier and rest amount of each type of unit depending on the terrain type are as below. Speed Matiplier Reu Duration Alier 1day Forester Mouraineer Forester Mounmaineer Forest 135 Moursain 14 Mansh 0.5 10 12 Qihers 0.85 011 After getting all this information, the program will move both the units to the target by printing out the total time (in hours) it took the units to reach their target and their final positions int he format seen in the outputs. Requirements: You should deline a class fort he unit, two CHILD classes of the unit class one for the forester unit, another fort he mountaineer unit. Coordinate information should be kept as private inside the unit class whereas the speed information shouldbe kept as protected inside the unit class. Classes should take the related input in their constructor functions Lhe base unit class MUST have a public function which prints out the current location of the unit. The base unit class MUST have a protected function which calculates the distance between itself and a target location. Each child classes MUST have a public function which moves the unit to a target location given the terrain Eype, calculates the total amount of hours it took the unit to reach to the target, and print it out Getting all the user input, instantiating objects, calling the move functions of the child classes should be done in the main() function. Do NOT use pollymorphisim in this question(i.e., do NOT overload the move functionof the base dass).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Concept of Light
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning