Thursday, August 15, 2019

Simple Geometric Calculator in C++

In this article a simple geometric calculator written in C++. The code shows you how to create a menu-driven program and the use of conditional statements in C++.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Program Listing


#include<iostream>

using namespace std;

int main(){
    int choice;
    cout<<"-- Simple Geometric Calculator --"<<endl;
    cout<<"- 1. Perimeter of Square       --"<<endl;
    cout<<"- 2. Perimeter of Rectangle    --"<<endl;
    cout<<"- 3. Area of Square            --"<<endl;
    cout<<"- 4. Area of Rectangle         --"<<endl;
    cout<<"---------------------------------"<<endl;
    cout<<"What is my choice :>";cin>>choice;
    if (choice==1)
    {
        double s,ps;
        cout<<"You have chosen Perimeter of Square"<<endl;
        cout<<"Enter side of Square :"; cin>>s;
        ps = 4*s;
        cout<<"Perimeter of Square is :"<<ps<<endl;
    }
    else if (choice==2)
    {
        double pl,ph,pr;
        cout<<"You have chosen Perimeter of Rectangle"<<endl;
        cout<<"Enter length of Rectangle :"; cin>>pl;
        cout<<"Enter height of Rectangle :"; cin>>ph;
        double setr = pl+ph;
        pr = setr*2;
        cout<<"Perimeter of Rectangle is :"<<pr;
    }
    else if (choice==3)
    {
        double ss,as;
        cout<<"You have chosen Area of Square"<<endl;
        cout<<"Enter side of Square :"; cin>>ss;
        as = ss * ss;
        cout<<"Area of Square is :"<<as;
    }
    else if (choice==4)
    {
        double al,ah,ar;
        cout<<"You have chosen Area of Rectangle"<<endl;
        cout<<"Enter length of Rectangle :"; cin>>al;
        cout<<"Enter height of Rectangle :"; cin>>ah;
        ar = al*ah;
        cout<<"Area of Rectangle is :"<<ar;
    }
return 0;
}


No comments:

Post a Comment