Vous êtes sur la page 1sur 1

SIN1001

Assignment 2 (6 %)

Due : 7 June 2016

1.

The cost per kilometer for a rental car is RM 3.50 for the first 100 kilometers, RM 2.80 for the next 200
kilometers and RM 2.00 for all kilometers in excess of 300 kilometers. Write a function that determines the
total cost for a given number of kilometers.

2.

The factorial of a non-negative integer is defined as,

n! n n 1 n 2

3 21.

Use a for loop to compute and print factorials. You should prompt the user for a non-negative integer and
check it is indeed non-negative.
3.

The energy loss due to fluid flow through a pipe can be calculated using the following equations,
2
L V
hL f
D 2
Q
V ,
A
D2
A
,
4
DV
Re
,

where,
hL = energy loss per mass of fluid fowing (J/kg),
f = friction factor (dimensionless),
L = pipe length (m),
D = pipe diameter (m),
V = average fluid velocity (m/s),
Q = volumetric flow rate (m3/s),
A = pipe cross-sectional area (m2),
Re = Reynolds number (dimensionless),
= fluid density (kg/m3),
= fluid viscosity (kg/ms).
The friction factor, f is calculated as,

64 ,
when Re 2000,
Re

2
5.0452 5.8506

2.01ln Re ln Re0.8981 , when Re 2000.

Write the function to calculate the energy loss per mass of flowing fluid for a fluid flow in a pipe, given the
pipe diameter, pipe length, fluid volumetric flow rate, fluid density and fluid viscosity. Test your fuction
with D = 0.2 m, L = 10 m, Q = 1 m3/s, = 1000 kg/m3 and = 0.001 kg/ms.

Vous aimerez peut-être aussi