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.
Addition of Two Numbers
Adding two numbers in programming is essentially the same as adding two numbers in general arithmetic. A significant difference is that in programming, you need to pay attention to the data type of the variable that will hold the sum of two numbers.
C++
C++ is a general-purpose hybrid language, which supports both OOPs and procedural language designed and developed by Bjarne Stroustrup. It began in 1979 as “C with Classes” at Bell Labs and first appeared in the year 1985 as C++. It is the superset of C programming language, because it uses most of the C code syntax. Due to its hybrid functionality, it used to develop embedded systems, operating systems, web browser, GUI and video games.
Write a C++ multi-file
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.
Unlock instant AI solutions
Tap the button
to generate a solution