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

حل السؤال

حل السؤال 13

import 'dart:io';
void main() {
  double m3Price = 0.3047;
  double deductionRate = 0.15;
  stdout.write('Enter the total payment amount: ');
  double total = double.parse(stdin.readLineSync()!);
  if (!total.isFinite || total < 0) {
    print('Invalid input: a finite nonnegative payment required.');
    return;
  }
  double deductionAmount = total * deductionRate;
  double gasCost = total - deductionAmount;
  double earnedGas = gasCost / m3Price;
  print('-------------------------------------');
  print('Total payment made = ${total.toStringAsFixed(2)}');
  print('Educational deduction (15%) = ${deductionAmount.toStringAsFixed(2)}');
  print('Gas cost = ${gasCost.toStringAsFixed(2)}');
  print('Earned Gas = ${earnedGas.toStringAsFixed(3)} M3');
}
العودة إلى السؤال نفسه