Pages

Using C# Program find (vi,vf,s,a,t) with help of Equation of motion.


INPUT

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace equation_of_motion
{
    class Program
    {
        static void Main(string[] args)
        {
            double vi, vf, t, s;
            double res;
            const double a = 9.8;
            Console.WriteLine("calculator for find out the different unknown values for equation of motion");

            Console.WriteLine("Please putt the values for getting ur answer and the value that is not usefull for ur formula putt 0");

            Console.WriteLine("Please enter value of vi");
            vi = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter the value of vf");
            vf = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter the value of t");
            t = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter tne value of s");
            s = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(" select the operation for finding the unknown value");
            Char op;
           
            Console.WriteLine("for finding s by having vi and t press 1");

            Console.WriteLine("for finding s by having vi and vf press 2");

            Console.WriteLine("for finding vf by having vi and s press 3");

            Console.WriteLine("for finding vf by having vi and t press 4");

            Console.WriteLine("for finding vi by having vf and t press 5");

            Console.WriteLine("for finding vi by having vf and s press 6");

            Console.WriteLine("for finding t by having vi and vf press 7");
            op = Convert.ToChar(Console.ReadLine());
           
                if (op == '1')
                {   res= (vi * t) + (a * (t * t)) / 2;
               
                    Console.WriteLine("s is equal to {0}", res);
                }
            else
           
                if (op == '2')

                {res= ((vf * vf) - (vi * vi)) / (2 * a);
               
                    Console.WriteLine("s is equal to {0}",res);
                }
           
                else
           
                if (op == '3')
                {res = Math.Sqrt((2 * a * s) + (vi * vi));
               
                    Console.WriteLine("vf is equal to {0}",res);
                }
           
                else

           
                if (op == '4')
                {res= vi + (a * t);
               
                    Console.WriteLine("vf is equal to {0}",res);
                }
           
                else
           
                if (op == '5')
                {res = vf - (a * t);
               
                    Console.WriteLine("vi is equal to {0}",res);
                }
           
                else

          
              
            if (op == '6')
            {res = Math.Sqrt((2 * a * s) - (vf * vf));
                
                    Console.WriteLine("vi is equal to {0}",res);
                }
           
            else
           
                if (op == '7')
                {res = (vf - vi) / a;
               

                    Console.WriteLine("t is equal to {0}",res);
                }
         }
      }
   }

OUTPUT:


No comments:

Post a Comment