Perimeter of kite

Write a program to find the perimeter of the kite.

Example 1:

Input: first_pair=3,second_pair=4
Output: 14

Approach: Given side of Kite in pair. 

Perimeter is 2*first_pair+2*second_pair

Java

public class PerimeterofKite {
    public static void main(String[] args) {
        double first_pair = 3;
        double second_pair = 4;
        double perimeter = perimeterKite(first_pair, second_pair);
        System.out.println("Perimeter of Kite is " + perimeter);
    }

    private static double perimeterKite(double first_pairdouble second_pair
{
        return 2 * first_pair + 2 * second_pair;
    }
}

C++

#include <bits/stdc++.h>
using namespace std;
//function to find the perimeter
//of the kite
double perimeterKite(double first_pair,double second_pair)
{
    double perimeter=2*first_pair+2*second_pair;
    return perimeter;

}
int main()
{
    double first_pair=3;
    double second_pair=4;
    double perimeter=perimeterKite(first_pair,second_pair);
    cout<<"Perimeter of Kite is ";
    cout<<perimeter<<"\n";
    return 0;
}


No comments:

Post a Comment