Pages

Write a program that find value from "pythagoras theorem" by using Methods

INPUT:

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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("~~~~~PYTHAGORAS THEOREM~~~~~");
            int p, b;
            Console.WriteLine("Please enter Perpendicular");
            p = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter Base");
            b = Convert.ToInt32(Console.ReadLine());
            double BSQR = bsqr(b);
            double PSQR = psqr(p);
            double SUMSQR = sumsqr(b, p);
            Console.WriteLine("Hyp {0}", SUMSQR);

        }
        public static double bsqr(int b)
        {
            double s;
            s = b * b;
            return s;
        }

        public static double psqr(int p)
        {
            double s;
            s = p * p;
            return s;
        }

        public static double sumsqr(int b, int p)
        {
            double s;
            s = b + p;
            s = Math.Sqrt(s);
            return s;
        }
    }

}
OUTPUT:


No comments:

Post a Comment