C++ homework help

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;
}
This shows what the result should be. I do not know how I go about doing things further with the code I have.

Enter your first and last name: Nicholson Manahan
Enter a distance in miles: 100000
Nicholson Manahan has traveled around the world 4 times.
Press any key to continue . . .
1
2
const float radius = 3959;
const float πœ‹ = 0;

Prefer floats over doubles when doing floating point calculations.
πœ‹ has an incorrect value.

I don't see where you've calculated the circumference.
cout << msytr << " has traveled around the world " << endl;
Not sure how you got

Nicholson Manahan has traveled around the world 4 times.
whats wrong with what you have so far?
idk if that variable for pi works though

you just have to say
cout << mystr << " has traveled around the world " << miles/(2*pi*radius) << " times." << endl;

if it has to be an integer then say (int)(miles/(2*pi*radius))

there might be some other problems that come up from using getline, but i dont remember exactly what happens, if anything at all. Just tell me what happens.
@smartypantzss It worked correctly. The integer one was the right one. Thank you for the help!

@integralfx The output should the "I have traveled around the world 4 times", but the problem is already solved. Thanks for the help!
Topic archived. No new replies allowed.