Hi guys,
I am having trouble with this assignment of mine: Write a complete C++ program that asks the user to enter their complete name and a distance
measure in miles. The program then displays the number of times the person would have
traveled around the world given the input distance value. Assume that the travel route around
the world is a perfect circle with a radius of 3,959 miles, so the distance traveling around the
world one time is equal to the circumference of the circle given by the formula 2ππ, where π is
the constant 3.14 and r is the radius of the circle.
Notes:
ο· Declare π and radius as constant variables.
ο· When prompting the user to enter name, you should allow a space between the first
and last name. Do not use separate variables for first and last name. The complete name
should be stored in one variable.
ο· Enter your first and last name when asked to enter name (not your instructorβs name)
And here's what I currently have. Could you guys please help me?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
int miles = 0;
const float radius = 3959;
const float π = 0;
cout << "********** AROUND THE WORLD **********" << endl << endl;
string msytr;
cout << "Enter your first and last name: ";
getline(cin, msytr);
cout << "Enter a distance in miles: ";
cin >> miles;
cout << msytr << " has traveled around the world " << endl;
return 0;
}
| |