Answer:
The programming language is not stated (I'll answer using C++)
#include <iostream>
using namespace std;
int convert(float miles)
{
return miles * 5280;
}
int main() {
cout<<"Console:"<<endl;
cout<<"Hike Calculator"<<endl;
float miles;
char response;
cout<<"How many miles did you walk?. ";
cin>>miles;
cout<<"You walked "<<convert(miles)<<" feet"<<endl;
cout<<"Continue? (y/n): ";
cin>>response;
while(response == 'y')
{
cout<<"How many miles did you walk?. ";
cin>>miles;
cout<<"You walked "<<convert(miles)<<" feet"<<endl;
cout<<"Continue? (y/n): ";
cin>>response;
}
cout<<"Bye!";
return 0;
}
Explanation:
Here, I'll explain some difficult lines (one after the other)
The italicized represents the function that returns the number of feet
<em>int convert(float miles)
</em>
<em>{
</em>
<em> return miles * 5280;
</em>
<em>}
</em>
The main method starts here
int main() {
The next two lines gives an info about the program
cout<<"Console:"<<endl;
cout<<"Hike Calculator"<<endl;
float miles;
char response;
This line prompts user for number of miles
cout<<"How many miles did you walk?. ";
cin>>miles;
This line calls the function that converts miles to feet and prints the feet equivalent of miles
cout<<"You walked "<<convert(miles)<<" feet"<<endl;
This line prompts user for another conversion
cout<<"Continue? (y/n): ";
cin>>response;
This is an iteration that repeats its execution as long as user continue input y as response
<em> while(response == 'y')
</em>
<em> {
</em>
<em> cout<<"How many miles did you walk?. ";
</em>
<em> cin>>miles;
</em>
<em> cout<<"You walked "<<convert(miles)<<" feet"<<endl;
</em>
<em> cout<<"Continue? (y/n): ";
</em>
<em> cin>>response;
</em>
<em> }
</em>
cout<<"Bye!";