Advertisement
Guest User

Untitled

a guest
May 25th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MathShit
  4. {
  5. internal class Program
  6. {
  7. private static void Main(string[] args)
  8. {
  9. Console.WriteLine("Are you solving for height or time? (h/t)");
  10.  
  11. if (Console.ReadLine() == "h")
  12. {
  13. float a, v, t, h_s;
  14. Console.WriteLine("acceleration of gravity?");
  15. a = Convert.ToSingle(Console.ReadLine());
  16. Console.WriteLine("velocity?");
  17. v = Convert.ToSingle(Console.ReadLine());
  18. Console.WriteLine("time?");
  19. t = Convert.ToSingle(Console.ReadLine());
  20. Console.WriteLine("Height?");
  21. h_s = Convert.ToSingle(Console.ReadLine());
  22. Console.WriteLine("The Height Is " + .5 * a * t * 2 * v * t + h_s + " In meters.");
  23. }
  24. else
  25. {
  26. float a, v, h_s;
  27. Console.WriteLine("acceleration of gravity?");
  28. a = Convert.ToSingle(Console.ReadLine());
  29. Console.WriteLine("velocity?");
  30. v = Convert.ToSingle(Console.ReadLine());
  31. Console.WriteLine("height?");
  32. h_s = Convert.ToSingle(Console.ReadLine());
  33. var t1 = v - Math.Sqrt(v * 2 * a * h_s) / (2 * a);
  34. var t2 = v + Math.Sqrt(v * 2 * a * h_s) / (2 * a);
  35. Console.WriteLine(string.Format("The Time Is: {0} And {1}", t1.ToString(), t2.ToString()));
  36. }
  37. Console.ReadLine();
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement