Jumat, 15 April 2011

program to find the area of ​​a circle and volume of a sphere

#include <iostream>
#include <stdlib.h>
#include <conio.h>
const float phi=3.14;

int main()
{
    int iter=0, pil, a;
    float volum, luas;
    bool loop=true;

    while(loop)
    {
        system("cls");
        cout << "Welcome to the program count"<< endl;
        cout << "You are at iteration-"<< iter << endl;
        cout << endl;
        cout << ">> Options Menu: "<< endl;
        cout << "1) Ball"<< endl;
        cout << "2) Circle"<< endl;
        cout << "0) Exit the program"<< endl;
        cout << endl;
        cout << "Please enter the number of your choice: ";
        cin >> pil;

        switch(pil)
        {
        case 1:
            cout << "Volume Calculation Ball" << endl;
            cout << "The length of the radius of ball = ";
            cin >> a;
            volum = 4/3 * phi * a * a * a;
            cout << "Volume = " << volum << endl;
            break;
        case 2:
            cout << "Calculation of Area of ​​a Circle" << endl;
            cout << "The length of the radius of the circle= ";
            cin >> a;
          luas = phi * a * a;
            cout << "Luas = " << luas << endl;
            break;
        case 0:
            loop = false;
            break;
        }

        cout << endl << "Press enter to return to the initial menu" << endl;

        getch();
        }
    return 0;
}

0 komentar:

Posting Komentar