본문 바로가기
.NET C#

자전거 칼로리 공식

by 태디 2023. 1. 15.
728x90
/// <summary>
/// 자전거 칼로리 공식
/// </summary>
/// <param name="weight">몸무게</param>
/// <param name="minute">운동시간(분)</param>
/// <param name="kph">평균속도</param>
/// <returns></returns>
public static double GetKcal(double totalTime, double kph)
{
    double minute = totalTime / 60;
    double weight = 0;

    List<GpsLogSetting> listSet = Utils.SetData.GetSetting<GpsLogSetting>();

    if (listSet.Count > 0)
        weight = Convert.ToDouble(listSet[0].WEIGHT);
    else
        weight = 0;

    double kcal = 0.0d;

    if (kph >= 0 && kph <= 13)
        kcal = 0.0650;
    else if (kph >= 14 && kph <= 16)
        kcal = 0.0783;
    else if (kph >= 17 && kph <= 19)
        kcal = 0.0939;
    else if (kph >= 20 && kph <= 22)
        kcal = 0.113;
    else if (kph >= 23 && kph <= 24)
        kcal = 0.124;
    else if (kph >= 25 && kph <= 26)
        kcal = 0.136;
    else if (kph == 27)
        kcal = 0.149;
    else if (kph >= 28 && kph <= 29)
        kcal = 0.163;
    else if (kph >= 30 && kph <= 31)
        kcal = 0.179;
    else if (kph >= 32)
        kcal = 0.196;
    else if (kph >= 33 && kph <= 34)
        kcal = 0.215;
    else if (kph >= 35 && kph <= 37)
        kcal = 0.259;
    else if (kph >= 40)
        kcal = 0.311;

    // 몸무게 x 평균 속도별 칼로리계수 * 분(운동시간)
    double result = Math.Round(weight * kcal * minute);
    result = Utils.Common.NaNValue(result);
    return result;
}

 

 public static double NaNValue(double value)
 {
     double rtnValue = !double.IsNaN(value) ? value : 0;
     return rtnValue;
 }

댓글