blob: efe8e106c2aecbf9c071c8cbac37987b48a5e094 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//Given that
mass = 2 //in kg
y1 = 5 //in meter
g = 9.8 //in m/s^2
ref = [0, 3, 5, 6]
//Sample Problem 8-2a
printf("**Sample Problem 8-2a**\n")
for x = ref
U = mass* g* (y1 - x)
printf("The potential energy at y1 is %dJ if reference is assumed to be at y=%d\n", U, x)
end
//sample Probelm 8-2b
printf("\n**Sample Problem 8-2b**\n")
y2 = 0
//The change in potential energy doesn't depend on choice of reference
deltaY = y2 - y1
//because the deltaY doesn't depend upon the choice of references
deltaU = mass* g* deltaY
printf("The change in potential energy is %dJ same for all the references", deltaU)
|