Music ku

Monday, March 07, 2011

Answer no2

#include<iostream.h>
main()
{
                float rectangular, circle, triangle, fahrenheit, celcius, radius,f,c;
                float width,height,base;
                char selection;

                cout<<"calculate:";
                cout<<"\n\n a-rectangular";
                cout<<" \nb-triangle";
                cout<<"\nc-circle";
                cout<<"\nd-fahrenheit";
                cout<<"\ne-celcius";


cout<<"\n\nenter selection";
cin>>selection;

if (selection=='a')
{
cout<<"\nYour Selection is a and you are calculate rectangular.";
               
                cout<<"\nenter width";
                cin>>width;
                                cout<<"\nenter height";
                                cin>>height;
                                rectangular=width*height;
cout<<"\nthe answer is"<<rectangular;
}

else if (selection=='b')
{

cout<<"\nYour Selection is b and you are calculate triangle.";
cout<<"\nenter base";
cin>>base;
cout<<"\nenter height";
cin>>height;

cout<<"\nthe answer is"<<triangle;
triangle=(1/2*base*height);
}

else if (selection=='c')
{
circle=3.142 * radius * radius;
cout<<"\nYour Selection is c and you are calculate circle.";
cout<<"\n enter radius";
cin>>radius;
cout<<"\nthe answer is"<<circle;
}

else if (selection=='d')
{
;
cout<<"\nYour Selection is d and you are calculate fahrenheit.";
fahrenheit=(celcius*1/8)+32;
cout<<"\nenter celcius";
cin>>c;
cout<<"\nthe answer is"<<fahrenheit;
}

else
{
cout<<"\nYour Selection is e and you are calculate celcius.";

cout<<"\nenter fahrenheit";
cin>>f;
cout<<"\nthe answer is"<<celcius;
celcius=(f-32)*(5/9);
}

return 0;
}

No comments:

Post a Comment