Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cmath>
- using namespace std;
- double isValidDimensions(double lenght, double diameter);
- double eval_volume(double lengthF, double diameterF);
- double eval_mass(double est_volumeF, double massF);
- void wedge_or_cylinder(double est_massF, double act_massF);
- int main()
- {
- double length = 0; double diameter = 0;
- double act_mass = 0;
- double est_volume = 0; double est_mass = 0;
- cout << "Enter the length:" << endl;
- cin >> length;
- cout << "Enter the diameter" << endl;
- cin >> diameter;
- cout << "Enter the actual weight:" << endl;
- cin >> act_mass;
- if (!isValidDimensions(length, diameter))
- // check len is within the range 1mm to 20mm and dia is in range 0.1mm - 1mm
- {
- cout << "Dimensions are not valid";
- }
- else
- {
- // estimate volume
- est_volume = eval_volume(length, diameter);
- // estimate weight, density 0.05
- est_mass = eval_mass(est_volume, 0.05);
- // display if wedge or cylinder
- wedge_or_cylinder(est_mass, act_mass);
- }
- return 0;
- }
- double isValidDimensions(double lenghtF, double diameterF)
- {
- double x = lenghtF;
- double y = diameterF;
- if( x >= 1 && x <=20 && y >= 0.1 && y <= 1 )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- double eval_volume(double lengthF, double diameterF)
- {
- double pi = 3.142;
- double x = lengthF;
- double y = diameterF;
- double volume = pi * pow(y, 2) * x;
- return volume;
- }
- double eval_mass(double est_volumeF, double massF)
- {
- double x = est_volumeF;
- double y = massF;
- double mass = (x * y);
- return mass;
- }
- void wedge_or_cylinder(double est_massF, double act_massF)
- {
- double x = est_massF;
- double y = act_massF;
- double z = x - y;
- if (z > 0.1)
- {
- cout << " The shard is wedge-shaped";
- }
- else
- cout << " The shard is cylinder shaped";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement