AREA.CPP. SOURCE CODE FOR FINDING AREA USING CALCULATOR.

/*AREA.CPP*/
#include "calculator.h"
#include <math.h>
#define PI 3.142
#include <iostream>
using namespace std;
void ScientificCalculator::area()
{
 cout<<"                  WELCOME TO THE AREA PORTION. HERE YOU CAN GET THE DIFFERENT AREAS OF SOME FIGURES.    "<<endl;
 cout<<endl;
 cout<<"CHOICE 1 IS THE AREA OF CIRCLE."<<endl<<"CHOICE 2 IS THE AREA OF RECTANGLE."<<endl<<"CHOICE 3 IS THE AREA OF SQUARE."<<endl<<"CHOICE 4 IS THE AREA OF TRAPEZIUM."<<endl;
 cout<<"Enter the choice: "<<endl;
 cin>>a;
 if(a==1)
 {
  cout<<"      AREA OF CIRCLE PORTION.  "<<endl;
  cout<<endl;
  cout<<"Enter the number: "<<endl;
  cin>>b;
  float area;
  area = PI * (b^2);
  cout<<"The area of circle is "<<area<<endl;
 }
 else if(a==2)
 {
  cout<<"    AREA OF RECTANGLE PORTION. "<<endl;
  cout<<endl;
  cout<<"Enter the number: "<<endl;
  cin>>b;
  int c;
  cout<<"Enter the other number: "<<endl;
  cin>>c;
  float area;
  area = b * c;
  cout<<"The area of rectangle is "<<area<<endl;
 }
 else if(a==3)
 {
  cout<<"    AREA OF SQUARE PORTION. "<<endl;
  cout<<endl;
  cout<<"Enter the number: "<<endl;
  cin>>b;
  float area;
  area = b * b;
  cout<<"The area of square is "<<area<<endl;
 }
 else if(a==4)
 {
  cout<<"    AREA OF TRAPEZIUM PORTION. "<<endl;
  cout<<endl;
  cout<<"Enter the height: "<<endl;
  cin>>b;
  cout<<"Enter the parallel sides: "<<endl;
  int c,d;
  cin>>c>>d;
  float area;
  area = (1/2) * b * (c + d);
  cout<<"The area of trapezium is "<<area<<endl;
 }
 else
  cout<<"The choice you have entered is invalid."<<endl;
}

Comments

Popular posts from this blog

Scientific Calculator Project Proposal