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

Test Data:
Enter the amount of celsius: 30
Expected Output:
Kelvin = 303
Fahrenheit = 86

Conversion Values.

Kelvin to Celsius: C = K - 273 (C = K - 273.15 if you want to be more precise)

Kelvin to Fahrenheit: F = 9/5(K - 273) + 32 or F = 1.8(K - 273) + 32

Celsius to Fahrenheit: F = 9/5(C) + 32 or F = 1.80(C) + 32

Celsius to Kelvin: K = C + 273 (or K = C + 271.15 to be more precise)

Fahrenheit to Celsius: C = (F - 32)/1.80

Fahrenheit to Kelvin: K = 5/9(F - 32) + 273.15


Code:

import 'dart:io';

void main() {
  stdout.write('Input Temperature in celsius : ');
  int celsius = int.parse(stdin.readLineSync());

  double kelvin = celsius.toDouble() + 273.0;
  double fahrenheit = (celsius * 1.80) + 32;
  print('Kelvin = ' + kelvin.toString());
  print('fahrenheit = ' + fahrenheit.toString());
}


Output:


Comments

Popular posts from this blog

Write a Dart program to create a new string from a given string (length 1 or more ) with the first character added at the front and back.