Write a complete C++ program to solve for the following problem. Background and formula : A vehicle travels from city A to city B via city C. The average speed of the vehicle can be calculated by the following formula: Average Speed = Distance from city A to city B + Distance from city B to city C Time taken to go from A to B + Time taken to go from B to C The time taken to cover any part of the journey can be calculated by the following formula: Time Taken from city X to city Y= Distance between X and Y Speed between X and Y The problem Fill in the blanks to find the average speed of the vehicle in its total journey from city A to city C using the above formulae. The program should get the input from a data file called “input.txt" for the following variable: 1. Distance between city A and city B (in kilometers (km)). 2. Distance between city B and city C (in kilometers (km)). 3. Speed of the vehicle while travelling from city A to city B (in kilometers per hour (km/h)). 4. Speed of the vehicle while travelling from city B to city C (in kilometers per hour (km/h)). The program should include a function named average speed that accepts the four input values as parameters and returns the average speed. The program should then display the average speed with 2 precision point. "input.txt" 5 10 50 60 12 30 35 40 30 32 55 80 5 6 30 55 24 45 65 35 15 43 33 44
Write a complete C++ program to solve for the following problem. Background and formula : A vehicle travels from city A to city B via city C. The average speed of the vehicle can be calculated by the following formula: Average Speed = Distance from city A to city B + Distance from city B to city C Time taken to go from A to B + Time taken to go from B to C The time taken to cover any part of the journey can be calculated by the following formula: Time Taken from city X to city Y= Distance between X and Y Speed between X and Y The problem Fill in the blanks to find the average speed of the vehicle in its total journey from city A to city C using the above formulae. The program should get the input from a data file called “input.txt" for the following variable: 1. Distance between city A and city B (in kilometers (km)). 2. Distance between city B and city C (in kilometers (km)). 3. Speed of the vehicle while travelling from city A to city B (in kilometers per hour (km/h)). 4. Speed of the vehicle while travelling from city B to city C (in kilometers per hour (km/h)). The program should include a function named average speed that accepts the four input values as parameters and returns the average speed. The program should then display the average speed with 2 precision point. "input.txt" 5 10 50 60 12 30 35 40 30 32 55 80 5 6 30 55 24 45 65 35 15 43 33 44
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY