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

حل السؤال

حل السؤال 54

import 'dart:io';
void main() {
  stdout.write("Please enter the numeric value: ");
  String userInput = stdin.readLineSync()!;
  double? value = double.tryParse(userInput);
  if (value == null || !value.isFinite || userInput.trim().isEmpty) {
    print("Please enter a valid numeric value.");
    return;
  }
  stdout.write("Does the value represent kilograms or pounds (kg/lb)? ");
  String unit = stdin.readLineSync()!.toLowerCase();
  value != null && (unit == "kg" || unit == "lb")
      ? unit == "kg"
      ? print("$value kilograms is equal to ${value * 2.20462} pounds.")
      : print("$value pounds is equal to ${value / 2.20462} kilograms.")
      : print("Unit is unknown. Please enter 'kg' or 'lb'.");
}
العودة إلى السؤال نفسه