Write a C++ multi-file program, called Distances. This program will calculate the sum of two distances. The distances will be declared as objects of a struct, Distance. struct Distance { int feet{ 0 }; int inches{ 0 }; }; There will be five functions: WriteHeader(); Goodbye(); DoAgain(); void AskForDistances(Distance &d1. Distance &d2); Distance CalcTotalDistance(Distance d1, Distance d2): In main(), begin by creating two struct objects from the Distance struct. Call WriteHeader() Open a do-while or while loop: Call AskForDistances, to get the user input. Call CalcTotalDistance and assign the return to a new struct variable, Distance totalD. Cout the total distance in feet and inches for the user. Call DoAgain() to ask if the user want to do another calculation and place the answer in the while part of the do-while loop.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Write a C++ multi-file program, called Distances. This program will calculate the sum of two distances. The distances will be declared as objects of a struct, Distance.

struct Distance {

int feet{ 0 };

int inches{ 0 };

};

There will be five functions:

WriteHeader();

Goodbye();

DoAgain();

void AskForDistances(Distance &d1. Distance &d2);

Distance CalcTotalDistance(Distance d1, Distance d2):

In main(), begin by creating two struct objects from the Distance struct.

Call WriteHeader()

Open a do-while or while loop: Call AskForDistances, to get the user input.

Call CalcTotalDistance and assign the return to a new struct variable, Distance totalD.

Cout the total distance in feet and inches for the user.

Call DoAgain() to ask if the user want to do another calculation and place the answer in the while part of the do-while loop.

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Introduction to Coding
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