How to simplify these conditions ? (engine model c program)
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
float enginerpm, torq;
torque()
{
if (enginerpm <1500)
{
torq = (0.03*(enginerpm - 1000)) + 160;
}
else
{
if (enginerpm <2000)
{
torq = (0.02*(enginerpm - 1500)) + 175;
}
else
{
if (enginerpm <2500)
{
torq = (0.02*(enginerpm - 2000)) + 185;
}
else
{
if (enginerpm <3000)
{
torq = (0.01*(enginerpm - 2500)) + 195;
}
else
{
if (enginerpm <3500)
{
torq = (0.01*(enginerpm - 3000)) + 200;
}
else
{
if (enginerpm <4000)
{
torq = (0.01*(enginerpm - 3500)) + 205;
}
else
{
if (enginerpm <4500)
{
torq = (0.01*(enginerpm - 4000)) + 210;
}
else
{
torq = 215;
}
}
}
}
}
}
}
}