Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use C++, comments that help in explaining how the code works are appreciated! Thanks! The scenario is that there are three truck drivers, that

Please use C++, comments that help in explaining how the code works are appreciated! Thanks! The scenario is that there are three truck drivers, that take turns in driving two trucks. If a driver wants to drive one of the trucks, the driver must use an access card. The card reader is attached to the truck door. Once the driver taps on the card reader, a set of information about the driver and the truck will be sent in the form of a text file. The information that will be sent is the "driver first name", "driver last name", "driver ID", "truck ID", and "truck location (x,y)". Once your program receives the information from the two trucks, it should calculate the distance between the two trucks. Moreover, it should calculate the distance between each truck and the origin (0,0), which represents the place where the truck parks every night.

Now, based on what's above, here are the requirements: 1. Design and implement a Driver class. 2. Design and implement a Location class. 3. Design and implement a Truck class that includes the driver and location as attributes. Also, the Truck class includes a function called distanceFrom(..). This function can be used to calculate the required distances. 4. Use the formula in the picture to calculate the distance between two locations. location1 = (x1, y1) and location2 = (x2, y2)

image text in transcribed 5. Use any sample data to test your code.

The output of the code must be the three required distances: The distance between the two trucks is: ? The distance between the truck (with ID = 111111) and the origin is: ? The distance between the truck (with ID = 222222) and the origin is: ?

d=2(x1x2)2+(y1y2)2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Identify the elements of a valid contract.

Answered: 1 week ago