Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  calcarea
Language: C/C++
Code:
#include <iostream>
#include <math.h>
 
using namespace std;
 
float calcArea (float fighting, float farming, float supporting, float pushing, float versatility){
    float cosAlfa = 0.951056516;
    float a1, a2, a3, a4, a5;
    float h;
    h = cosAlfa*fighting; a1=sqrt((fighting*fighting)-(h*h))*cosAlfa*fighting;
    h = cosAlfa*farming; a2=sqrt((farming*farming)-(h*h))*cosAlfa*farming;
    h = cosAlfa*supporting; a3=sqrt((supporting*supporting)-(h*h))*cosAlfa*supporting;
    h = cosAlfa*pushing; a4=sqrt((pushing*pushing)-(h*h))*cosAlfa*pushing;
    h = cosAlfa*versatility; a5=sqrt((versatility*versatility)-(h*h))*cosAlfa*versatility;
 
    return a1+a2+a3+a4+a5;
}
 
int main()
{
    float fighting;
    float farming;
    float supporting;
    float pushing;
    float versatility;
    float area;
    int a;
 
    cout << "Enter your fighting value: "; cin >> fighting;
    cout << "\nEnter your farming value: "; cin >> farming;
    cout << "\nEnter your supporting value: "; cin >> supporting;
    cout << "\nEnter your pushing value: "; cin >> pushing;
    cout << "\nEnter your versatility value: "; cin >> versatility;
 
    area = calcArea(fighting, farming, supporting, pushing, versatility);
    a=(12*area)/1.46946;
 
    cout << "\nYour area is: "<< area;
    cout << "\nAnd it is: " << 100*area/1.46946 << "% of the max area.";
    cout << "\nI'd say it is a " << a <<"/12.";
    cin>>a;
    return 0;
}
Comments: