Distance traveled program problem.

Can anyone help me write a program for school? I am fairly new to programming and would appreciate some help.
The problem:
The velocity of a truck moving in one dimensional motion is given by the expression below.
v=0.25t^3
Write a program that will numerically estimate the distance traveled by the truck in the first 4 seconds of motion. Have it estimate using time intervals of 0.01 s.
your distance function is going to be the integral of this, distance = (1/16)t^4 . Plug in 4 and you have a total distance of 16
your distance function is going to be the integral of this, ...

Given the requirement that a time interval of 0.01 secs is to be used for the estimate I don't think the integral solution is relevant here!?

Write a program that will numerically estimate the distance traveled by the truck ...

Basically, you need to add up the distance travelled in each 0.01 sec interval.

I assume you know how to code a loop in C++? And to do arithmetic? And output?

Andy
Last edited on
@andywestken the loop can be from 1 to 400. Each .01 seconds can be put into the integral I have defined above. Absolutely the integral is relevant here.
@hello, you meant:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// pseudo code
// pick out your unit system, I 'd go with meter and second
//
// then : distance in meter -> hint double
// then : time in second  -> hint double
// then : speed in meter/second  -> hint double

func speed(distance, time) // returns meter per second
{
    return distance / time;
}

func distance(speed, time) // returns meters
{
    return speed * time;
}

func time(distance, speed) // returns seconds
{
    return distance / speed;
}
Last edited on
Topic archived. No new replies allowed.