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

حل السؤال

حل السؤال 30

import 'dart:io';
void main() {
  stdout.write('Enter your gross monthly income: ');
  double monthlyIncome =
                    double.parse(stdin.readLineSync()!);
  if (!monthlyIncome.isFinite || monthlyIncome < 0) {
    print('Invalid input: a finite nonnegative income required.');
    return;
  }
  double annualIncome = monthlyIncome * 12;
  double totalTax = 0;
  if (annualIncome <= 10700) {
    totalTax = annualIncome * 0.15;
  } else if (annualIncome <= 26000) {
    totalTax = 1605 + (annualIncome - 10700) * 0.20;
  } else if (annualIncome <= 94000) {
    totalTax = 4665 + (annualIncome - 26000) * 0.27;
  } else {
    totalTax = annualIncome * 0.35;
  }
  double monthlyTax = totalTax / 12;
  double netMonthlyIncome = monthlyIncome - monthlyTax;
  print('Your total annual income: ${annualIncome.toStringAsFixed(2)} TL');
  print('Total tax to be paid: ${totalTax.toStringAsFixed(2)} TL');
  print('Monthly tax deduction: ${monthlyTax.toStringAsFixed(2)} TL');
  print('Net monthly income after tax deduction: ${netMonthlyIncome.toStringAsFixed(2)} TL');
}
العودة إلى السؤال نفسه