Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Print out conversion table. (25 pts) Use \"for\" or \"while\" loop statements

ID: 3699089 • Letter: 3

Question

3. Print out conversion table. (25 pts) Use "for" or "while" loop statements, write a C++ program to generate the following table showing unit conversions from Miles to Kilometers and also from Kilometers to Miles. The results are shown in 3 decimal digits. (Note: 1 mie 1.609 kilometers) EN "C:Documents and SettingsClaralMy Documents11 Teaching Miles Kilometers Kiloneters Miles 1.609 3.218 4.827 6.136 8.045 9.654 11.263 12.872 14.481 16.890 20 25 30 35 48 45 50 12.430 15.538 18.645 21.753 24.860 27.968 31.075 34.183 37.290 48.398 60 65 0 Press any key to continue The program will be named using your first and last name, such as "JohnSmith 3.cpp"

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
cout<<"Miles Kilometers | Kilometers Miles"<<endl;
for(int i=1,j=20;i<=10;i++,j+=5) {
cout<<i<<" "<<i*1.609<<" | "<<j<<" "<<j/1.609<<endl;
}

return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote