فهرس الكتباللغة البرمجية دارت

حل السؤال

حل السؤال 35

import 'dart:io';
void main() {
  stdout.write('Enter your gender (m/M - f/F): ');
  String gender = stdin.readLineSync()!.toLowerCase();
  stdout.write('Enter your height (m): ');
  double height = double.parse(stdin.readLineSync()!);
  stdout.write('Enter your weight (kg): ');
  double weight = double.parse(stdin.readLineSync()!);
  double idealWeight;
  if (gender == 'm') {
    idealWeight = 48 + (height - 1.5) / 0.025 * 2.7;
  } else if (gender == 'f') {
    idealWeight = 45 + (height - 1.5) / 0.025 * 2.2;
  } else {
    print('Invalid gender entered. Enter "m" or "f".');
    return;
  }
  String result = 'Your weight is ideal';
  if (weight < idealWeight) {
    result = 'You weigh less than your ideal weight.';
  } else if (weight > idealWeight) {
    result = 'You weigh more than your ideal weight.';
  }
  print('---------------------------------');
  print('Your ideal weight: ${idealWeight.toStringAsFixed(2)} kg');
  print(result);
}
العودة إلى السؤال نفسه