fork(7) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public enum WeightType
  6. {
  7. Pounds,
  8. Grams,
  9. Ounces,
  10. Kilograms
  11. }
  12.  
  13. public static void ConvertToPounds(double weight, WeightType type)
  14. {
  15. switch (type)
  16. {
  17. case WeightType.Kilograms:
  18. {
  19. double pounds = weight * 2.20462d;
  20. double ounces = pounds - Math.Floor(pounds);
  21. pounds -= ounces;
  22. ounces *= 16;
  23. Console.WriteLine("{0} lbs and {1} oz.", pounds, ounces);
  24. break;
  25. }
  26. default:
  27. throw new Exception("Weight type not supported");
  28. }
  29. }
  30.  
  31. public static void Main()
  32. {
  33. const int sampleSize = 3000;
  34. const WeightType type = WeightType.Kilograms;
  35. ConvertToPounds(sampleSize, type);
  36. }
  37. }
Success #stdin #stdout 0.03s 33864KB
stdin
Standard input is empty
stdout
6613 lbs and 13.7599999999948 oz.