Write a Dart program that takes four numbers as input to calculate and print the average

Code:
import 'dart:io';

void main() {
  print('Input first number : ');
  int a = int.parse(stdin.readLineSync());
  print('Input second number : ');
  int b = int.parse(stdin.readLineSync());
  print('Input third number : ');
  int c = int.parse(stdin.readLineSync());
  print('Input fourth number : ');
  int d = int.parse(stdin.readLineSync());
  print('Average of $a,$b,$c,$d = ${((a + b + c + d) / 4).round()}');
}

Output:

Comments

Popular posts from this blog

Write a Dart program to convert from celsius degrees to Kelvin and Fahrenheit.

Write a Dart program to check two given integers and return true if one is negative and one is positive

Write a Dart program to compute the sum of two given integers, if two values are equal then return the triple of their sum