•Женщины: BMR= 9,99 * вес (в кг) + 6,25 * рост (в см) - 4,92 * возраст (количество лет) -161
•Мужчины: BMR = 9,99 * вес (в кг) + 6,25 * рост (в см) - 4,92 * возраст (количество лет) + 5
C/C++
Можете составить код к этой формуле на языке С++
#include <iostream>
#include <iomanip>
using namespace std;
class Human {
public:
Human() : weight(0), height(0), age(0) {}
virtual int kilocalories()const = 0;
protected:
int weight;
int height;
int age;
double calc()const {
return kw * weight + kh * height - ka * age;
}
private:
inline static const auto kw = 9.99;
inline static const auto kh = 6.25;
inline static const auto ka = 4.92;
};
class Man : public Human {
public:
Man(int weight, int height, int age) {
this->weight = weight;
this->height = height;
this->age = age;
}
int kilocalories()const override {
return static_cast<int>(calc() + x);
}
private:
static const auto x = 5;
};
class Woman : public Human {
public:
Woman(int weight, int height, int age) {
this->weight = weight;
this->height = height;
this->age = age;
}
int kilocalories()const override {
return static_cast<int>(calc() - x);
}
private:
static const auto x = 161;
};
int integer(const char* msg) {
cout << msg;
int value;
cin >> value;
cin.ignore(cin.rdbuf()->in_avail());
return value;
}
int main() {
system("chcp 1251 > nul");
auto wm = integer("Вес мужчины, кг: ");
auto hm = integer("Рост мужчины, см: ");
auto am = integer("Возраст мужчины, полн. года: ");
Man man{ wm, hm, am };
auto xm = man.kilocalories();
cout << "Расчёт килокалорий для мужчины: " << xm << '\n';
auto ww = integer("Вес жещины, кг: ");
auto hw = integer("Рост жещины, см: ");
auto aw = integer("Возраст жещины, полн. года: ");
Woman woman{ ww, hw, aw };
auto xw = woman.kilocalories();
cout << "Расчёт килокалорий для жещины: " << xw << '\n';
system("pause > nul");
}
#include <iomanip>
using namespace std;
class Human {
public:
Human() : weight(0), height(0), age(0) {}
virtual int kilocalories()const = 0;
protected:
int weight;
int height;
int age;
double calc()const {
return kw * weight + kh * height - ka * age;
}
private:
inline static const auto kw = 9.99;
inline static const auto kh = 6.25;
inline static const auto ka = 4.92;
};
class Man : public Human {
public:
Man(int weight, int height, int age) {
this->weight = weight;
this->height = height;
this->age = age;
}
int kilocalories()const override {
return static_cast<int>(calc() + x);
}
private:
static const auto x = 5;
};
class Woman : public Human {
public:
Woman(int weight, int height, int age) {
this->weight = weight;
this->height = height;
this->age = age;
}
int kilocalories()const override {
return static_cast<int>(calc() - x);
}
private:
static const auto x = 161;
};
int integer(const char* msg) {
cout << msg;
int value;
cin >> value;
cin.ignore(cin.rdbuf()->in_avail());
return value;
}
int main() {
system("chcp 1251 > nul");
auto wm = integer("Вес мужчины, кг: ");
auto hm = integer("Рост мужчины, см: ");
auto am = integer("Возраст мужчины, полн. года: ");
Man man{ wm, hm, am };
auto xm = man.kilocalories();
cout << "Расчёт килокалорий для мужчины: " << xm << '\n';
auto ww = integer("Вес жещины, кг: ");
auto hw = integer("Рост жещины, см: ");
auto aw = integer("Возраст жещины, полн. года: ");
Woman woman{ ww, hw, aw };
auto xw = woman.kilocalories();
cout << "Расчёт килокалорий для жещины: " << xw << '\n';
system("pause > nul");
}
BMR=9.99*weight+6.25*height-4.92*age+(sex==male? 5:-161);
Похожие вопросы
- Можете составить код к этой формуле на языке С++. буду очень благодарен
- Помогите составить код на C++ ,заранее спасибо)
- Как написать код для этого задания на языке С++
- Помогите пожалуйста не могу написать код
- В чём заключается ошибка? (не могу запустить код)
- Не могу написать код на с++ нужно решать через циклы но если у вас другие варианты пишите тоже желательно циклы
- Написать код на языке си
- Написать код на языке C++
- Написал код для языка C, но работает не правильно
- Язык Си.помогите написать формулу пожалуйста