Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,398 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,245 people online right now. Registration is fast and FREE... Join Now!




HELP

 
Reply to this topicStart new topic

HELP, CODE PROBLEM

rijaalu
post 22 Aug, 2008 - 07:00 AM
Post #1


New D.I.C Head

*
Joined: 5 Jan, 2008
Posts: 6

please i need some help with this code below . my problem is the minutes and second ..

[size=5][b]1. four track stars entered the mile race at the penn relays . write a programm that scans in the race time in minutes(minutes) and seconds (seconds) for a runner and computes and display the speed in feet per second (fps) and in meters per second(mps). (hints: there are 5280 feet in one mile, and one kilometer equals 3282 feet.) wriet and call a function that displays instructions to the program user.run the program for each star's data.
minutes. seconds
3 52.83
3 59.83
4 00.03
4 16.22

THIS IS MY CODE
CODE

#include <stdio.h>
#include <stdlib.h>

double tracks(double x,double n, int m);

int main(void)
{

    
double minutes, seconds, feets,distance ,speed;

printf("Enter the minutes:\n");
scanf("%lf", &minutes);

printf("Enter the seconds :\n");
scanf("%lf", &seconds);

printf("Enter the distance in feet:\n");
scanf("%lf", &feets );

distance = feets * 0.3048;
speed = tracks(distance, minutes,seconds);

printf(" the speed of the track star is %.2f meter per second\n\n", speed);

system("PAUSE");

return 0;
}

double tracks(double x,double n, int m)
{

return (  x / n * m );
}
User is offlineProfile CardPM

Go to the top of the page

Jayman
post 22 Aug, 2008 - 02:54 PM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,839



Thanked 38 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Can you describe what specifically the problem is?

Include any error messages or expected output that you are getting.
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 22 Aug, 2008 - 03:04 PM
Post #3


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,402



Thanked 94 times

Dream Kudos: 2625

Expert In: Dingleberries

My Contributions


First off, let's explain the situation. If you take into consideration how you can calculate speed. DST.
CODE
  D
S   T


Speed == distance / time;

So, let's use a float to store the time, in seconds.
float time;
Then, we use scanf() to read in the minutes into time, like so:
scanf ("%f", &time);
Next, we need to multiply time by 60, giving us the minutes in seconds.
time *= 60;
Now, let's get the seconds:
float seconds;
scanf ("%f", &seconds);
And add that to time:
time += seconds;
Now, we have a time, in seconds, after scanning minutes and seconds.
Let's get the distance, now:
float distance;
scanf ("%f", &distance);

So, going back to what I said at the beginning of my response:
float fps = distance / time; // fps = speed
And that is our feet per second.
Now all you need to do is add the output, and convert the distance, and repeat the speed for mps and kps.

Hope this helps smile.gif
Hint: if it was, click here wink.gif
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 07:36AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month