Exercise 1: Fill in the missing code in these operations involving struct Distan
ID: 3655654 • Letter: E
Question
Exercise 1: Fill in the missing code in these operations involving struct Distance. Exercise 2: Fill in the missing code in function main. Exercise 3: Write a function that takes a variable of type Distance and a time (in minutes) and calculates miles per hour. //***************************************************** // Program Distance converts either yards or feet to // a record of type Distance. //***************************************************** #include using namespace std; struct Distance { long feet; long yards; long miles; }; Distance ConvertYards(long yards); // Post: yards has been converted into a variable of // type Distance. Distance ConvertFeet(long feet); // Post: feet has been converted into a variable of // type Distance. void PrintDistance(Distance distance); // Post: A vriable of type Distance is printed as feet, // yards, and miles. int main() { // FILL IN code to test the operations involving // struct Distance. } //********* Distance Operations ******************** Distance ConvertYards(long yards) { // FILL IN Code to convert yards to a variable of Distance. } //****************************************************** Distance ConvertFeet(long feet) { // FILL IN Code to convert feet to a variable of Distance. } //****************************************************** void PrintDistance(Distance Distance) { // FILL IN Code to print a variable of Distance. }Explanation / Answer
#include using namespace std; struct Distance { long feet; long yards; long miles; }; long mph(Distance,int ); Distance ConvertYards(long yards); // Post: yards has been converted into a variable of // type Distance. Distance ConvertFeet(long feet); // Post: feet has been converted into a variable of //type Distance. void PrintDistance(Distance distance); // Post: A vriable of type Distance is printed as feet, // yards, and miles. int main() { // FILL IN code to test the operations involving // struct Distance. int yard,feet,minute; Distance inyards,infeet; long FeetToMPH; coutfeet; coutyard; infeet=ConvertFeet(feet); inyards=ConvertYards(yard); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.