So the first part of the question asks to construct a function that converts miles to kilometers which I did. But the second part asks to split the display into two columns rather than one. Something like this:
Miles = Kilometers Miles = Kilometers
(Hint: Find split = (start + stop)/2. Let a loop execute from miles = start to split, and
calculate and print across one line the values of miles and kilometers for both miles and
(miles - start + split + 1).)
Here's the code I have so far which only displays it in one column.
One thing you might do: When they give you a hint, define things in terms of the hint (although in this case your hint contains incorrect information.)
1 2 3 4 5 6 7 8 9 10 11 12 13
int main()
{
constdouble kmPerMile = 1.61 ;
unsigned start = 1 ;
unsigned stop = 20 ;
// The following is what your hint should've said for calculating split.
unsigned split = (stop-start+1) / 2 ;
for ( unsigned miles = ? ; miles <= ? ; ++miles )
cout << miles << ' ' << miles*kmPerMile << '\t' << ? << ' ' << ?*kmPerMile << '\n' ;
}