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

حل السؤال

حل السؤال 36

import 'dart:io';
void main() {
  stdout.write("Enter the consumed quantity (kWh): ");
  double quantity = double.parse(stdin.readLineSync()!);
  if (!quantity.isFinite || quantity < 0) {
    print('Invalid input: finite nonnegative kWh required.');
    return;
  }
  double bill = 0.0;
  if (quantity <= 50) {
    bill = quantity * 0.50;
  } else if (quantity > 50 && quantity <= 100) {
    bill = quantity  * 0.75;
  } else {
    bill = quantity * 1.0;
  }
  double additional = bill * 0.20;
  double total = bill + additional;
  print("Consumption cost = $bill \$");
  print("Additional Fee = $additional \$");
  print("Total Consumption Bill = $total \$");
}
العودة إلى السؤال نفسه