1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
//
// main.cpp
// Phuong_assignment_A
//
// Created by Phuong Pham on 9/29/16.
// Copyright © 2016 Phuong Pham. All rights reserved.
//
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
const double PI = 3.14159265358979323846;
struct Cone
{
double height, radius;
};
void input (double &height, double &radius);
void setUp( Cone *ptr,double &height,double &radius);
double getVolume(Cone *ptr);
void outPut(Cone *ptr);
int main(int argc, const char * argv[])
{
double height=0, radius=0;
Cone *ptr = new Cone();
input(height,radius);
setUp(ptr,height,radius);
outPut(ptr);
delete (ptr);
return 0;
}
void input (double &height, double &radius)
{
cout << "Input your height"<< endl;
cin >> height;
cout << "Input your radius"<< endl;
cin >> radius;
}
void setUp( Cone *ptr,double &height,double &radius)
{
ptr->height=height;
ptr->radius=radius;
}
double getVolume(Cone *ptr)
{
double a=ptr->height;
double b=ptr->radius;
double Volume;
Volume = (PI * pow(b, 2) * a)/3.0;
return Volume;
}
void outPut(Cone *ptr)
{
getVolume(ptr);
cout <</*"Height: "<<height<<endl<<"Radius: "<<radius<<endl<<"Volume: "<<*/getVolume(ptr)<<endl;
}
|