I'm new to C++ and I need help in writing code:

Lucy likes to jog in the morning.
As she jogs, she counts the number of strides, she makes during the first minute and then again during the last minute of her jogging.
She then averages these two numbers together and calls this the average the number of strides she makes during a minute.

Write a program that asks for the number of strides made during the first minute and the number of strides made during the last minute (each an integer) and then asks for the total number of hours and minutes that Lucy jogs. (each an integer)
Assume Lucy’s stride length is 2.5 feet. Using the fact that there are 5280 feet in a mile, have your program display the average number of strides Lucy makes in a minute (a float) and the distance Lucy jogged in miles (a float)

Below is a sample run….your code should work for any input I choose .

What was the number of strides you made during the first minute?
128
What was the number of strides you made during the last minute?
123
How many hours did you jog?
1
How many minutes did you jog?
15
Your average number of strides per minute is: 125.5
The distance you jogged was: 4.46 miles

HINT:
The magic code to print a float to 2 places is (we will learn more about this later in the course)
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

Post the code you have tried. If you don't know where to start, then start here

#include <iostream>

using std::cin;
using std::cout;

int main()
{
   // code goes here
}

Write the program just a little bit at a time and you won't get overwhelmed about the program's complexity.

#include <iostream>
using namespace std;

int main()
{
float numMiles, numMinutes
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "How many miles: ";
cin >> numMiles;
cout << "How many minutes: ";
cin >> numMinutes;
cin>> numHours;
cout<< ”How many hours:”;

cout << The miles per hour achieved was "
<< numMiles / numhours << '\n';

return 0;
}

First, please use code tags [code] //code here [/code].

You've been given a sample output, and your code doesn't match. Try to get your program to produce those phrases verbatim. After that, try putting in all the input steps, and then add in the math. Do it in stages like Ancient Dragon recommended.

You're answering a different question with your code, so that would have to be addressed, too.

I will write the program for you. ;)

commented: Spammer -1

This is what I have so far, any help you can give me will be appreciated.
Thank You!

#include  <iostream>
using namespace std;

int main()
{
Int number_of_feet, feet_per_minutes, feet_per_miles, miles_hour;
float numMinutes, numMiles
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << " What was the number of feet made during the first minute: ";
cin >> numFeet;
cout << " What was the number of feet made during the last minute: ";
cin >> numFeet;
cout << “What is the average number of feet:”;
cin >> “numAvfeet;
cout<<” How many hours jogged:”;
cin >> numHours;
cout << “How many minutes jogged:”;
cin >> numMinutes;
cout << “How many jogged miles per hour:";
cout<< numMiles / numHours << '\n';

return 0;
}

Assume Lucy’s stride length is 2.5 feet. Using the fact that there are 5280 feet in a mile, have your program display the average number of strides Lucy makes in a minute (a float) and the distance Lucy jogged in miles (a float)

You have still not even matched up your prompts with those in the example. Little details are important.

You have two constants that you have not defined anywhere. Also, does your program answer the question asked??

Thanks for taking the time to help, you have been a tremendous help.

Thank You for taking the time to help me.

Have a Nice Day!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.